Background

Open-Meteo maintains an API for historical weather that allows for non-commercial usage of historical weather data maintained by the website.

This file builds on _v001, _v002, and _v003 to run exploratory analysis on some historical weather data.

Functions and Libraries

The exploration process uses tidyverse, ranger, several generic custom functions, and several functions specific to Open Meteo processing. First, tidyverse, ranger, and the generic functions are loaded:

library(tidyverse) # tidyverse functionality is included throughout
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'purrr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'stringr' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ranger) # predict() does not work on ranger objects unless ranger has been called
## Warning: package 'ranger' was built under R version 4.2.3
source("./Generic_Added_Utility_Functions_202105_v001.R") # Basic functions

Next, specific functions written in _v001 are copied:

# Helper function for reading a partial CSV file
partialCSVRead <- function(loc, firstRow=1L, lastRow=+Inf, col_names=TRUE, ...) {
    
    # FUNCTION arguments
    # loc: file location
    # firstRow: first row that is relevant to the partial file read (whether header line or data line)
    # last Row: last row that is relevant to the partial file read (+Inf means read until last line of file)
    # col_names: the col_names parameter passed to readr::read_csv
    #            TRUE means header=TRUE (get column names from file, read data starting on next line)
    #            FALSE means header=FALSE (auto-generate column names, read data starting on first line)
    #            character vector means use these as column names (read data starting on first line)
    # ...: additional arguments passed to read_csv

    # Read the file and return
    # skip: rows to be skipped are all those prior to firstRow
    # n_max: maximum rows read are lastRow-firstRow, with an additional data row when col_names is not TRUE
    readr::read_csv(loc, 
                    col_names=col_names,
                    skip=firstRow-1, 
                    n_max=lastRow-firstRow+ifelse(isTRUE(col_names), 0, 1), 
                    ...
                    )
    
}


# Get the break points for gaps in a vector (e.g., 0, 3, 5:8, 20 has break points 0, 3, 5, 20 and 0, 3, 8, 30)
vecGaps <- function(x, addElements=c(), sortUnique=TRUE) {
    
    if(length(addElements)>0) x <- c(addElements, x)
    if(isTRUE(sortUnique)) x <- unique(sort(x))
    list("starts"=c(x[is.na(lag(x)) | x-lag(x)>1], +Inf), 
         "ends"=x[is.na(lead(x)) | lead(x)-x>1]
         )
    
}


# Find the break points in a single file
flatFileGaps <- function(loc) {

    which(stringr::str_length(readLines(loc))==0) %>% vecGaps(addElements=0)
    
}


# Read all relevant data as CSV with header
readMultiCSV <- function(loc, col_names=TRUE, ...) {

    gaps <- flatFileGaps(loc)
    
    lapply(seq_along(gaps$ends), 
           FUN=function(x) partialCSVRead(loc, 
                                          firstRow=gaps$ends[x]+1, 
                                          lastRow=gaps$starts[x+1]-1, 
                                          col_names=col_names, 
                                          ...
                                          )
           )
    
}


# Create URL with specified parameters for downloading data from Open Meteo
openMeteoURLCreate <- function(mainURL="https://archive-api.open-meteo.com/v1/archive", 
                               lat=45, 
                               lon=-90, 
                               startDate=paste(year(Sys.Date())-1, "01", "01", sep="-"), 
                               endDate=paste(year(Sys.Date())-1, "12", "31", sep="-"), 
                               hourlyMetrics=NULL, 
                               dailyMetrics=NULL,
                               tz="GMT", 
                               ...
                               ) {
    
    # Create formatted string
    fString <- paste0(mainURL, 
                      "?latitude=", 
                      lat, 
                      "&longitude=", 
                      lon, 
                      "&start_date=", 
                      startDate, 
                      "&end_date=", 
                      endDate
                      )
    if(!is.null(hourlyMetrics)) fString <- paste0(fString, "&hourly=", hourlyMetrics)
    if(!is.null(dailyMetrics)) fString <- paste0(fString, "&daily=", dailyMetrics)
    
    # Return the formatted string
    paste0(fString, "&timezone=", stringr::str_replace(tz, "/", "%2F"), ...)
    
}


# Helper function to simplify entry of parameters for Open Meteo download requests
helperOpenMeteoURL <- function(cityName=NULL,
                               lat=NULL,
                               lon=NULL,
                               hourlyMetrics=NULL,
                               hourlyIndices=NULL,
                               hourlyDesc=tblMetricsHourly,
                               dailyMetrics=NULL,
                               dailyIndices=NULL,
                               dailyDesc=tblMetricsDaily,
                               startDate=NULL, 
                               endDate=NULL, 
                               tz=NULL,
                               ...
                               ) {
    
    # Convert city to lat/lon if lat/lon are NULL
    if(is.null(lat) | is.null(lon)) {
        if(is.null(cityName)) stop("\nMust provide lat/lon or city name available in maps::us.cities\n")
        cityData <- maps::us.cities %>% tibble::as_tibble() %>% filter(name==cityName)
        if(nrow(cityData)!=1) stop("\nMust provide city name that maps uniquely to maps::us.cities$name\n")
        lat <- cityData$lat[1]
        lon <- cityData$long[1]
    }
    
    # Get hourly metrics by index if relevant
    if(is.null(hourlyMetrics) & !is.null(hourlyIndices)) {
        hourlyMetrics <- hourlyDesc %>% slice(hourlyIndices) %>% pull(metric)
        hourlyMetrics <- paste0(hourlyMetrics, collapse=",")
        cat("\nHourly metrics created from indices:", hourlyMetrics, "\n\n")
    }
    
    # Get daily metrics by index if relevant
    if(is.null(dailyMetrics) & !is.null(dailyIndices)) {
        dailyMetrics <- dailyDesc %>% slice(dailyIndices) %>% pull(metric)
        dailyMetrics <- paste0(dailyMetrics, collapse=",")
        cat("\nDaily metrics created from indices:", dailyMetrics, "\n\n")
    }
    
    # Use default values from OpenMeteoURLCreate() for startDate, endDate, and tz if passed as NULL
    if(is.null(startDate)) startDate <- eval(formals(openMeteoURLCreate)$startDate)
    if(is.null(endDate)) endDate <- eval(formals(openMeteoURLCreate)$endDate)
    if(is.null(tz)) tz <- eval(formals(openMeteoURLCreate)$tz)
    
    # Create and return URL
    openMeteoURLCreate(lat=lat,
                       lon=lon, 
                       startDate=startDate, 
                       endDate=endDate, 
                       hourlyMetrics=hourlyMetrics, 
                       dailyMetrics=dailyMetrics, 
                       tz=tz,
                       ...
                       )
    
}


# Read JSON data returned from Open Meteo
readOpenMeteoJSON <- function(js, mapDaily=tblMetricsDaily, mapHourly=tblMetricsHourly) {
    
    # FUNCTION arguments: 
    # js: JSON list returned by download from Open-Meteo
    # mapDaily: mapping file for daily metrics
    # mapHourly: mapping file for hourly metrics
    
    # Get the object and names
    jsObj <- jsonlite::read_json(js, simplifyVector = TRUE)
    nms <- jsObj %>% names()
    cat("\nObjects in JSON include:", paste(nms, collapse=", "), "\n\n")
    
    # Set default objects as NULL
    tblDaily <- NULL
    tblHourly <- NULL
    tblUnitsDaily <- NULL
    tblUnitsHourly <- NULL
    
    # Get daily and hourly as tibble if relevant
    if("daily" %in% nms) tblDaily <- jsObj$daily %>% tibble::as_tibble() %>% omProcessDaily()
    if("hourly" %in% nms) tblHourly <- jsObj$hourly %>% tibble::as_tibble() %>% omProcessHourly()
    
    # Helper function for unit conversions
    helperMetricUnit <- function(x, mapper, desc=NULL) {
        if(is.null(desc)) 
            desc <- as.list(match.call())$x %>% 
                deparse() %>% 
                stringr::str_replace_all(pattern=".*\\$", replacement="")
        x %>% 
            tibble::as_tibble() %>% 
            pivot_longer(cols=everything()) %>% 
            left_join(mapper, by=c("name"="metric")) %>% 
            mutate(value=stringr::str_replace(value, "\u00b0", "deg ")) %>% 
            mutate(metricType=desc) %>% 
            select(metricType, everything())
    }
    
    # Get the unit descriptions
    if("daily_units" %in% nms) tblUnitsDaily <- helperMetricUnit(jsObj$daily_units, mapDaily)
    if("hourly_units" %in% nms) tblUnitsHourly <- helperMetricUnit(jsObj$hourly_units, mapHourly)
    if(is.null(tblUnitsDaily) & !is.null(tblUnitsHourly)) tblUnits <- tblUnitsHourly
    else if(!is.null(tblUnitsDaily) & is.null(tblUnitsHourly)) tblUnits <- tblUnitsDaily
    else if(!is.null(tblUnitsDaily) & !is.null(tblUnitsHourly)) 
        tblUnits <- bind_rows(tblUnitsHourly, tblUnitsDaily)
    else tblUnits <- NULL
    
    # Put everything else together
    tblDescription <- jsObj[setdiff(nms, c("hourly", "hourly_units", "daily", "daily_units"))] %>%
        tibble::as_tibble()
    
    # Return the list objects
    list(tblDaily=tblDaily, tblHourly=tblHourly, tblUnits=tblUnits, tblDescription=tblDescription)
    
}


# Return Open meteo metadata in prettified format
prettyOpenMeteoMeta <- function(df, extr="tblDescription") {
    if("list" %in% class(df)) df <- df[[extr]]
    for(name in names(df)) {
        cat("\n", name, ": ", df %>% pull(name), sep="")
    }
    cat("\n\n")
}


# Process Open Meteo daily data
omProcessDaily <- function(tbl, extr="tblDaily") {
    if("list" %in% class(tbl)) tbl <- tbl[[extr]]
    tbl %>% mutate(date=lubridate::ymd(time)) %>% select(date, everything())
}


# Process Open meteo hourly data
omProcessHourly <- function(tbl, extr="tblHourly") {
    if("list" %in% class(tbl)) tbl <- tbl[[extr]]
    tbl %>% 
        mutate(origTime=time, 
               time=lubridate::ymd_hm(time), 
               date=lubridate::date(time), 
               hour=lubridate::hour(time)
               ) %>% 
        select(time, date, hour, everything())
}


# Simple predictive model for categorical variable
simpleOneVarPredict <- function(df, 
                                tgt, 
                                prd, 
                                dfTest=NULL,
                                nPrint=30, 
                                showPlot=TRUE, 
                                returnData=TRUE
                                ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame or tibble with key elements (training data set)
    # tgt: target variable
    # prd: predictor variable
    # dfTest: test dataset for applying predictions
    # nPrint: maximum number of lines of confusion matrix to print
    #         0 means do not print any summary statistics
    # showPlot: boolean, should overlap plot be created and shown?
    
    # Counts of predictor to target variable
    dfPred <- df %>%
        group_by(across(all_of(c(prd, tgt)))) %>%
        summarize(n=n(), .groups="drop") %>%
        arrange(across(all_of(prd)), desc(n)) %>%
        group_by(across(all_of(prd))) %>%
        mutate(correct=row_number()==1, predicted=first(get(tgt))) %>%
        ungroup()

    # Confusion matrix and accuracy
    dfConf <- dfPred %>%
        group_by(across(all_of(c(tgt, "correct")))) %>%
        summarize(n=sum(n), .groups="drop") %>%
        pivot_wider(id_cols=tgt, names_from=correct, values_from=n, values_fill=0) %>%
        mutate(n=`TRUE`+`FALSE`, 
               pctCorrect=`TRUE`/n, 
               pctNaive=1/(nrow(.)), 
               lift=pctCorrect/pctNaive-1
               )
    
    # Overall confusion matrix
    dfConfAll <- dfConf %>%
        summarize(nMax=max(n), across(c(`FALSE`, `TRUE`, "n"), sum)) %>%
        mutate(pctCorrect=`TRUE`/n, 
               pctNaive=nMax/n, 
               lift=pctCorrect/pctNaive-1, 
               nBucket=length(unique(dfPred[[prd]]))
               )
    
    # Print confusion matrices
    if(nPrint > 0) {
        cat("\nAccuracy by target subgroup (training data):\n")
        dfConf %>% print(n=nPrint)
        cat("\nOverall Accuracy (training data):\n")
        dfConfAll %>% print(n=nPrint)
    }
    
    # Plot of overlaps
    if(isTRUE(showPlot)) {
        p1 <- dfPred %>%
            group_by(across(c(all_of(tgt), "predicted", "correct"))) %>%
            summarize(n=sum(n), .groups="drop") %>%
            ggplot(aes(x=get(tgt), y=predicted)) + 
            labs(x="Actual", 
                 y="Predicted", 
                 title=paste0("Training data - Actual vs. predicted ", tgt), 
                 subtitle=paste0("(using ", prd, ")")
                 ) + 
            geom_text(aes(label=n)) + 
            geom_tile(aes(fill=correct), alpha=0.25)
        print(p1)
    }
    
    # Create metrics for test dataset if requested
    if(!is.null(dfTest)) {
        # Get maximum category from training data
        mostPredicted <- count(dfPred, predicted, wt=n) %>% slice(1) %>% pull(predicted)
        # Get mapping of metric to prediction
        dfPredict <- dfPred %>% 
            group_by(across(all_of(c(prd, "predicted")))) %>% 
            summarize(n=sum(n), .groups="drop")
        # Create predictions for test data
        dfPredTest <- dfTest %>%
            select(all_of(c(prd, tgt))) %>%
            left_join(select(dfPredict, -n)) %>%
            replace_na(list(predicted=mostPredicted)) %>%
            group_by(across(all_of(c(prd, tgt, "predicted")))) %>%
            summarize(n=n(), .groups="drop") %>%
            mutate(correct=(get(tgt)==predicted))
        # Create confusion statistics for test data
        dfConfTest <- dfPredTest %>%
            group_by(across(all_of(c(tgt, "correct")))) %>%
            summarize(n=sum(n), .groups="drop") %>%
            pivot_wider(id_cols=tgt, names_from=correct, values_from=n, values_fill=0) %>%
            mutate(n=`TRUE`+`FALSE`, 
                   pctCorrect=`TRUE`/n, 
                   pctNaive=1/(nrow(.)), 
                   lift=pctCorrect/pctNaive-1
                   )
        # Overall confusion matrix for test data
        dfConfAllTest <- dfConfTest %>%
            summarize(nMax=max(n), across(c(`FALSE`, `TRUE`, "n"), sum)) %>%
            mutate(pctCorrect=`TRUE`/n, 
                   pctNaive=nMax/n, 
                   lift=pctCorrect/pctNaive-1, 
                   nBucket=length(unique(dfConfTest[[prd]]))
               )
        # Print confusion matrices
        if(nPrint > 0) {
            cat("\nAccuracy by target subgroup (testing data):\n")
            dfConfTest %>% print(n=nPrint)
            cat("\nOverall Accuracy (testing data):\n")
            dfConfAllTest %>% print(n=nPrint)
            }
    } else {
        dfPredTest <- NULL
        dfConfTest <- NULL
        dfConfAllTest <- NULL
        
    }
    
    # Return data if requested
    if(isTRUE(returnData)) list(dfPred=dfPred, 
                                dfConf=dfConf, 
                                dfConfAll=dfConfAll, 
                                dfPredTest=dfPredTest, 
                                dfConfTest=dfConfTest, 
                                dfConfAllTest=dfConfAllTest
                                )
    
}


# Fit a single predictor to a single categorical variable
simpleOneVarFit <- function(df, 
                            tgt, 
                            prd, 
                            rankType="last", 
                            naMethod=TRUE
                            ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame or tibble with key elements (training data set)
    # tgt: target variable
    # prd: predictor variable
    # rankType: method for breaking ties of same n, passed to base::rank as ties.method=
    # naMethod: method for handling NA in ranks, passed to base::rank as na.last=
    
    # Counts of predictor to target variable, and associated predictions
    df %>%
        group_by(across(all_of(c(prd, tgt)))) %>%
        summarize(n=n(), .groups="drop") %>%
        arrange(across(all_of(prd)), desc(n), across(all_of(tgt))) %>%
        group_by(across(all_of(prd))) %>%
        mutate(rankN=n()+1-rank(n, ties.method=rankType, na.last=naMethod)) %>%
        arrange(across(all_of(prd)), rankN) %>%
        ungroup()

}


# Create categorical predictions mapper
simpleOneVarMapper <- function(df, tgt, prd) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame or tibble from SimpleOneVarFit()
    # tgt: target variable
    # prd: predictor variable
    
    # Get the most common actual results
    dfCommon <- df %>% count(across(all_of(tgt)), wt=n, sort=TRUE)
    
    # Get the predictions
    dfPredictor <- df %>%
        group_by(across(all_of(prd))) %>%
        filter(row_number()==1) %>%
        select(all_of(c(prd, tgt))) %>%
        ungroup()
    
    list(dfPredictor=dfPredictor, dfCommon=dfCommon)
    
}


# Map the categorical predictions to unseen data
simpleOneVarApplyMapper <- function(df, 
                                    tgt,
                                    prd, 
                                    mapper, 
                                    mapperDF="dfPredictor", 
                                    mapperDefault="dfCommon",
                                    prdName="predicted"
                                    ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame containing prd for predicting tgt
    # tgt: target variable in df
    # prd: predictor variable in df
    # mapper: mapping list from sinpleOneVarMapper()
    # mapperDF: element that can be used to merge mappings
    # mapperDefault: element that can be used for NA resulting from merging mapperDF
    # prdName: name for the prediction variable
    
    # Extract the mapper and default value
    vecRename <- c(prdName) %>% purrr::set_names(tgt)
    dfMap <- mapper[[mapperDF]] %>% select(all_of(c(prd, tgt))) %>% colRenamer(vecRename=vecRename)
    chrDefault <- mapper[[mapperDefault]] %>% slice(1) %>% pull(tgt)
    
    # Merge mappings to df
    df %>%
        left_join(dfMap, by=prd) %>%
        replace_na(list("predicted"=chrDefault))
    
}


# Create confusion matrix data for categorical predictions
simpleOneVarConfusionData <- function(df, 
                                      tgtOrig,
                                      tgtPred, 
                                      otherVars=c(),
                                      weightBy="n"
                                      ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame from simpleOneVarApplyMapper()
    # tgtOrig: original target variable name in df
    # tgtPred: predicted target variable name in df
    # otherVars: other variables to be kept (will be grouping variables)
    # weightBy: weighting variable for counts in df (NULL means count each row of df as 1)
    
    # Confusion matrix data creation
    df %>%
        group_by(across(all_of(c(tgtOrig, tgtPred, otherVars)))) %>%
        summarize(n=if(!is.null(weightBy)) sum(get(weightBy)) else n(), .groups="drop") %>%
        mutate(correct=get(tgtOrig)==get(tgtPred))
    
}


# Print and plot confusion matrix for categorical predictions
simpleOneVarConfusionReport <- function(df, 
                                        tgtOrig,
                                        tgtPred, 
                                        otherVars=c(), 
                                        printConf=TRUE,
                                        printConfOrig=printConf, 
                                        printConfPred=printConf,
                                        printConfOverall=printConf, 
                                        plotConf=TRUE, 
                                        plotDesc="",
                                        nBucket=NA, 
                                        predictorVarName="", 
                                        returnData=FALSE
                                        ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame from simpleOneVarConfusionData()
    # tgtOrig: original target variable name in df
    # tgtPred: predicted target variable name in df
    # otherVars: other variables to be kept (will be grouping variables) - NOT IMPLEMENTED
    # printConf: boolean, should confusion matrix data be printed? Applies to all three
    # printConfOrig: boolean, should confusion data be printed based on original target variable?
    # printConfPred: boolean, should confusion data be printed based on predicted target variable?
    # printConfOverall: boolean, should overall confusion data be printed?
    # plotConf: boolean, should confusion overlap data be plotted?
    # plotDesc: descriptive label to be included in front of plot title
    # nBucket: number of buckets used for prediction (pass from previous data)
    # predictorVarName: variable name to be included in chart description
    # returnData: boolean, should the confusion matrices be returned?
    
    # Confusion data based on original target variable
    if(isTRUE(printConfOrig) | isTRUE(returnData)) {
        dfConfOrig <- df %>%
            group_by(across(all_of(c(tgtOrig)))) %>%
            summarize(right=sum(n*correct), wrong=sum(n)-right, n=sum(n), .groups="drop") %>%
            mutate(pctRight=right/n, pctNaive=n/(sum(n)), lift=pctRight/pctNaive-1)
    }

    # Confusion data based on predicted target variable
    if(isTRUE(printConfPred) | isTRUE(returnData)) {
        dfConfPred <- df %>%
            group_by(across(all_of(c(tgtPred)))) %>%
            summarize(right=sum(n*correct), wrong=sum(n)-right, n=sum(n), .groups="drop") %>%
            mutate(pctRight=right/n)
    }

    # Overall confusion data
    if(isTRUE(printConfOverall) | isTRUE(returnData)) {
        maxNaive <- df %>%
            group_by(across(all_of(tgtOrig))) %>%
            summarize(n=sum(n), .groups="drop") %>%
            arrange(desc(n)) %>%
            slice(1) %>%
            pull(n)
        dfConfOverall <- df %>%
            summarize(right=sum(n*correct), wrong=sum(n)-right, n=sum(n), .groups="drop") %>%
            mutate(maxN=maxNaive, pctRight=right/n, pctNaive=maxN/n, lift=pctRight/pctNaive-1, nBucket=nBucket)
    }
    
    # Confusion report based on original target variable
    if(isTRUE(printConfOrig)) {
        cat("\nConfusion data based on original target variable:", tgtOrig, "\n")
        dfConfOrig %>%
            print(n=50)
    }

    # Confusion report based on predicted target variable
    if(isTRUE(printConfPred)) {
        cat("\nConfusion data based on predicted target variable:", tgtPred, "\n")
        dfConfPred %>%
            print(n=50)
    }
    
    # Overall confusion matrix
    if(isTRUE(printConfOverall)) {
        cat("\nOverall confusion matrix\n")
        dfConfOverall %>%
            print(n=50)
    }
    
    # Plot of overlaps
    if(isTRUE(plotConf)) {
        p1 <- df %>%
            group_by(across(all_of(c(tgtOrig, tgtPred, "correct")))) %>%
            summarize(n=sum(n), .groups="drop") %>%
            ggplot(aes(x=get(tgtOrig), y=get(tgtPred))) + 
            labs(x="Actual", 
                 y="Predicted", 
                 title=paste0(plotDesc, "Actual vs. predicted ", tgtOrig), 
                 subtitle=paste0("(using ", predictorVarName, ")")
                 ) + 
            geom_text(aes(label=n)) + 
            geom_tile(aes(fill=correct), alpha=0.25)
        print(p1)
    }
    
    # Return data if requested
    if(isTRUE(returnData)) list(dfConfOrig=dfConfOrig, dfConfPred=dfConfPred, dfConfOverall=dfConfOverall)
    
}


# Process for chaining predictor, applier, and confusion matrix for categorical variables
simpleOneVarChain <- function(df,
                              tgt,
                              prd,
                              mapper=NULL, 
                              rankType="last", 
                              naMethod=TRUE, 
                              printReport=TRUE, 
                              plotDesc="",
                              returnData=TRUE, 
                              includeConfData=FALSE
                              ) {

    # FUNCTION ARGUMENTS:
    # df: data frame or tibble with key elements (training or testing data set)
    # tgt: target variable
    # prd: predictor variable
    # mapper: mapping file to be applied for predictions (NULL means create from simpleOneVarApply())
    # rankType: method for breaking ties of same n, passed to base::rank as ties.method=
    # naMethod: method for handling NA in ranks, passed to base::rank as na.last=    
    # printReport: boolean, should the confusion report data and plot be printed?
    # plotDesc: descriptive label to be included in front of plot title
    # returnData: boolean, should data elements be returned?
    # includeConfData: boolean, should confusion data be returned?
    
    # Create the summary of predictor-target-n
    dfFit <- simpleOneVarFit(df, tgt=tgt, prd=prd, rankType=rankType, naMethod=naMethod)     

    # Create the mapper if it does not already exist
    if(is.null(mapper)) mapper <- simpleOneVarMapper(dfFit, tgt=tgt, prd=prd)
    
    # Apply mapper to data
    dfApplied <- simpleOneVarApplyMapper(dfFit, tgt=tgt, prd=prd, mapper=mapper)

    # Create confusion data
    dfConfusion <- simpleOneVarConfusionData(dfApplied, tgtOrig=tgt, tgtPred="predicted")
    
    # Create confusion report if requested
    if(isTRUE(printReport) | isTRUE(includeConfData)) {
        dfConfReport <- simpleOneVarConfusionReport(df=dfConfusion, 
                                                    tgtOrig=tgt, 
                                                    tgtPred="predicted", 
                                                    nBucket=length(unique(dfApplied[[prd]])), 
                                                    predictorVarName=prd, 
                                                    printConf=printReport, 
                                                    plotConf=printReport,
                                                    plotDesc=plotDesc,
                                                    returnData=includeConfData
                                                    )
    }
    
    # Return data if requested
    if(isTRUE(returnData)) {
        ret <- list(dfFit=dfFit, mapper=mapper, dfApplied=dfApplied, dfConfusion=dfConfusion)
        if(isTRUE(includeConfData)) ret<-c(ret, list(dfConfData=dfConfReport))
        ret
    }
    
}


# Adds a train-test component for single variable predictions
simpleOneVarTrainTest <- function(dfTrain,
                                  dfTest,
                                  tgt,
                                  prd,
                                  rankType="last", 
                                  naMethod=TRUE, 
                                  printReport=FALSE, 
                                  includeConfData=TRUE, 
                                  returnData=TRUE
                              ) {

    # FUNCTION ARGUMENTS:
    # dfTrain: data frame or tibble with key elements (training data set)
    # dfTest: data frame or tibble with key elements (testing data set)
    # tgt: target variable
    # prd: predictor variable
    # rankType: method for breaking ties of same n, passed to base::rank as ties.method=
    # naMethod: method for handling NA in ranks, passed to base::rank as na.last=    
    # printReport: boolean, should the confusion report data and plot be printed?
    # includeConfData: boolean, should confusion data be returned?
    # returnData: boolean, should data elements be returned?
    
    # Fit the training data
    tmpTrain <- simpleOneVarChain(df=dfTrain, 
                                  tgt=tgt, 
                                  prd=prd,
                                  rankType=rankType,
                                  naMethod=naMethod,
                                  printReport=printReport,
                                  plotDesc="Training data: ",
                                  returnData=TRUE,
                                  includeConfData=includeConfData
                                  )
    
    # Fit the testing data
    tmpTest <- simpleOneVarChain(df=dfTest, 
                                 tgt=tgt, 
                                 prd=prd,
                                 mapper=tmpTrain$mapper,
                                 rankType=rankType,
                                 naMethod=naMethod,
                                 printReport=printReport,
                                 plotDesc="Testing data: ",
                                 returnData=TRUE,
                                 includeConfData=includeConfData
                                 )
    
    # Return data if requested
    if(isTRUE(returnData)) list(tmpTrain=tmpTrain, tmpTest=tmpTest)
    
}


# Plot the means by cluster and variable for a k-means object
plotClusterMeans <- function(km, nrow=NULL, ncol=NULL, scales="fixed") {

    # FUNCTION ARGUMENTS
    # km: object returned by stats::kmeans(...)
    # nrow: number of rows for faceting (NULL means default)
    # ncol: number of columns for faceting (NULL means default)
    # scales: passed to facet_wrap as scales=scales
    
    # Assess clustering by dimension
    p1 <- km$centers %>%
        tibble::as_tibble() %>%
        mutate(cluster=row_number()) %>%
        pivot_longer(cols=-c(cluster)) %>%
        ggplot(aes(x=fct_reorder(name, 
                                 value, 
                                 .fun=function(a) ifelse(length(a)==2, a[2]-a[1], diff(range(a)))
                                 ), 
                   y=value
                   )
               ) + 
        geom_point(aes(color=factor(cluster))) + 
        scale_color_discrete("Cluster") + 
        facet_wrap(~factor(cluster), nrow=nrow, ncol=ncol, scales=scales) +
        labs(title=paste0("Cluster means (kmeans, centers=", nrow(km$centers), ")"), 
             x="Metric", 
             y="Cluster mean"
             ) + 
        geom_hline(yintercept=median(km$centers), lty=2) +
        coord_flip()
    print(p1)
    
}


# Plot percentage by cluster
plotClusterPct <- function(df, km, keyVars, nRowFacet=1, printPlot=TRUE) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame initially passed to stats::kmeans(...)
    # km: object returned by stats::kmeans(...)
    # keyVars: character vector of length 1 (y-only, x will be cl) or length 2 (x, y, cl will facet)
    # nRowFacet: number of rows for facetting (only relevant if length(keyVars) is 2)
    # printPlot: boolean, should plot be printed? (if not true, plot will be returned)
    
    # Check length of keyVars
    if(!(length(keyVars) %in% c(1, 2))) stop("\nArgument keyVars must be length-1 or length-2\n")
    
    p1 <- df %>%
        mutate(cl=factor(km$cluster)) %>%
        group_by(across(c(all_of(keyVars), "cl"))) %>%
        summarize(n=n(), .groups="drop") %>%
        group_by(across(all_of(keyVars))) %>%
        mutate(pct=n/sum(n)) %>%
        ungroup() %>%
        ggplot() + 
        scale_fill_continuous(low="white", high="green") + 
        labs(title=paste0("Percentage by cluster (kmeans with ", nrow(km$centers), " centers)"), 
             x=ifelse(length(keyVars)==1, "Cluster", keyVars[1]), 
             y=ifelse(length(keyVars)==1, keyVars[1], keyVars[2])
             )
    if(length(keyVars)==1) p1 <- p1 + geom_tile(aes(fill=pct, x=cl, y=get(keyVars[1])))
    if(length(keyVars)==2) {
        p1 <- p1 + 
            geom_tile(aes(fill=pct, x=get(keyVars[1]), y=get(keyVars[2]))) + 
            facet_wrap(~cl, nrow=nRowFacet)
    }
    
    if(isTRUE(printPlot)) print(p1)
    else return(p1)
    
}


# Run k-means (or use passed k-means object) and plot centers and percentages of observations
runKMeans <- function(df, 
                      km=NULL,
                      vars=NULL, 
                      centers=2, 
                      nStart=1L, 
                      iter.max=10L, 
                      seed=NULL, 
                      plotMeans=FALSE,
                      nrowMeans=NULL,
                      plotPct=NULL, 
                      nrowPct=1, 
                      returnKM=is.null(km)
                      ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame for clustering
    # km: k-means object (will shut off k-means processing and run as plot-only)
    # vars: variables to be used for clustering (NULL means everything in df)
    # centers: number of centers
    # nStart: passed to kmeans
    # iter.max: passed to kmeans
    # seed: seed to be set (if NULL, no seed is set)
    # plotMeans: boolean, plot variable means by cluster?
    # nrowMeans: argument passed as nrow for faceting rows in plotClusterMeans() - NULL is default ggplot2
    # plotPct: list of character vectors to be passed sequentially as keyVars to plotClusterPct()
    #          NULL means do not run
    #          pctByCluster=list(c("var1"), c("var2", "var3")) will run plotting twice
    # nrowPct: argument for faceting number of rows in plotClusterPct()
    # returnKM: boolean, should the k-means object be returned?
    
    # Set seed if requested
    if(!is.null(seed)) set.seed(seed)
    
    # Get the variable names if passed as NULL
    if(is.null(vars)) vars <- names(df)
    
    # Run the k-means process if the object has not been passed
    if(is.null(km)) {
        km <- df %>%
            select(all_of(vars)) %>% 
            kmeans(centers=centers, iter.max=iter.max, nstart=nStart)
    }

    # Assess clustering by dimension if requested
    if(isTRUE(plotMeans)) plotClusterMeans(km, nrow=nrowMeans)
    if(!is.null((plotPct))) 
        for(ctr in 1:length(plotPct)) 
            plotClusterPct(df=df, km=km, keyVars=plotPct[[ctr]], nRowFacet=nrowPct)
    
    # Return the k-means object
    if(isTRUE(returnKM)) return(km)
    
}


# Assign points to closest center of a passed k-means object
assignKMeans <- function(km, df, returnAllDistanceData=FALSE) {
    
    # FUNCTION ARGUMENTS:
    # km: a k-means object
    # df: data frame or tibble
    # returnAllDistanceData: boolean, should the distance data and clusters be returned?
    #                        TRUE returns a data frame with distances as V1, V2, ..., and cluster as cl
    #                        FALSE returns a vector of cluster assignments as integers
    
    # Select columns from df to match km
    df <- df %>% select(all_of(colnames(km$centers)))
    if(!all.equal(names(df), colnames(km$centers))) stop("\nName mismatch in clustering and frame\n")
    
    # Create the distances and find clusters
    distClust <- sapply(seq_len(nrow(km$centers)), 
                        FUN=function(x) sqrt(rowSums(sweep(as.matrix(df), 
                                                           2, 
                                                           t(as.matrix(km$centers[x,,drop=FALSE]))
                                                           )**2
                                                     )
                                             )
                        ) %>% 
        as.data.frame() %>% 
        tibble::as_tibble() %>% 
        mutate(cl=apply(., 1, which.min))
    
    # Return the proper file
    if(isTRUE(returnAllDistanceData)) return(distClust)
    else return(distClust$cl)
    
}

As well, specific functions from _v002 and _v003 are copied:

runSimpleRF <- function(df, yVar, xVars=NULL, ...) {

    # FUNCTION ARGUMENTS:
    # df: data frame containing observations
    # yVar: variable to be predicted (numeric for regression, categorical for classification)
    # xVars: predictor variables (NULL means everything in df except for yVar)
    # ...: other arguments passed to ranger::ranger
    
    # Create xVars if passed as NULL
    if(is.null(xVars)) xVars <- setdiff(names(df), yVar)
    
    # Simple random forest model
    ranger::ranger(as.formula(paste0(yVar, "~", paste0(xVars, collapse="+"))), 
                   data=df[, c(yVar, xVars)], 
                   ...
                   )
    
}

plotRFImportance <- function(rf, 
                             impName="variable.importance", 
                             divBy=1000, 
                             plotTitle=NULL, 
                             plotData=TRUE, 
                             returnData=!isTRUE(plotData)
                             ) {
    
    # FUNCTION ARGUMENTS:
    # rf: output list from random forest with an element for importance
    # impName: name of the element to extract from rf
    # divBy: divisor for the importance variable
    # plotTitle: title for plot (NULL means use default)
    # plotData: boolean, should the importance plot be created and printed?
    # returnData: boolean, should the processed data be returned?
    
    # Create title if not provided
    if(is.null(plotTitle)) plotTitle <- "Importance for simple random forest"

    # Create y-axis label
    yAxisLabel="Variable Importance"
    if(!isTRUE(all.equal(divBy, 1))) yAxisLabel <- paste0(yAxisLabel, " (", divBy, "s)")
    
    # Create variable importance
    df <- rf[[impName]] %>% 
        as.data.frame() %>% 
        purrr::set_names("imp") %>% 
        rownames_to_column("metric") %>% 
        tibble::as_tibble() 
    
    # Create and print plot if requested
    if(isTRUE(plotData)) {
        p1 <- df %>%
            ggplot(aes(x=fct_reorder(metric, imp), y=imp/divBy)) + 
            geom_col(fill="lightblue") + 
            labs(x=NULL, y=yAxisLabel, title=plotTitle) +
            coord_flip()
        print(p1)
    }
    
    # Return data if requested
    if(isTRUE(returnData)) return(df)
    
}

predictRF <- function(rf, df, newCol="pred", predsOnly=FALSE) {
    
    # FUNCTION ARGUMENTS:
    # rf: a trained random forest model
    # df: data frame for adding predictions
    # newCol: name for new column to be added to df
    # predsOnly: boolean, should only the vector of predictions be returned?
    #            if FALSE, a column named newCol is added to df, with df returned

    # Performance on holdout data
    preds <- predict(rf, data=df)$predictions
    
    # Return just the predictions if requested otherwise add as final column to df
    if(isTRUE(predsOnly)) return(preds)
    else {
        df[newCol] <- preds
        return(df)
    }
    
}

# Update for continuous variables
reportAccuracy <- function(df, 
                           trueCol, 
                           predCol="pred", 
                           reportAcc=TRUE, 
                           rndReport=2, 
                           useLabel="requested data",
                           returnAcc=!isTRUE(reportAcc), 
                           reportR2=FALSE
                           ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame containing actual and predictions
    # trueCol: column containing true value
    # predCol: column containing predicted value
    # reportAcc: boolean, should accuracy be reported (printed to output)?
    # rndReport: number of significant digits for reporting (will be converted to percentage first)
    # useLabel: label for data to be used in reporting
    # returnAcc: boolean, should the accuracy be returned 
    #            return value is not converted to percentage, not rounded
    # reportR2: boolean, should accuracy be calculated as R-squared?
    #           (default FALSE measures as categorical)
    
    # Continuous or categorical reporting
    if(isTRUE(reportR2)) {
        tc <- df %>% pull(get(trueCol))
        pc <- df %>% pull(get(predCol))
        mseNull <- mean((tc-mean(tc))**2)
        msePred <- mean((tc-pc)**2)
        r2 <- 1 - msePred/mseNull
        if(isTRUE(reportAcc)) 
            cat("\nR-squared of ", 
                useLabel, 
                " is: ", 
                round(100*r2, rndReport), 
                "% (RMSE ",
                round(sqrt(msePred), 2), 
                " vs. ", 
                round(sqrt(mseNull), 2),
                " null)\n", 
                sep=""
                )
        acc <- c("mseNull"=mseNull, "msePred"=msePred, "r2"=r2)
    } else {
        acc <- mean(df[trueCol]==df[predCol])
        if(isTRUE(reportAcc)) 
            cat("\nAccuracy of ", useLabel, " is: ", round(100*acc, rndReport), "%\n", sep="")    
    }
    
    # Return accuracy statistic if requested
    if(isTRUE(returnAcc)) return(acc)
    
}

# Update for automated rounding
plotConfusion <- function(df, 
                          trueCol, 
                          predCol="pred", 
                          useTitle=NULL,
                          useSub=NULL, 
                          plotCont=FALSE, 
                          rndTo=NULL,
                          rndBucketsAuto=100,
                          nSig=NULL,
                          refXY=FALSE
                          ) {
    
    # FUNCTION ARGUMENTS:
    # df: data frame containing actual and predictions
    # trueCol: column containing true value
    # predCol: column containing predicted value
    # useTitle: title to be used for chart (NULL means create from trueCol)
    # useSub: subtitle to be used for chart (NULL means none)
    # plotCont: boolean, should plotting assume continuous variables?
    #           (default FALSE assumes confusion plot for categorical variables)
    # rndTo: every number in x should be rounded to the nearest rndTo
    #        NULL means no rounding (default)
    #        -1L means make an estimate based on data
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)
    # refXY: boolean, should a reference line for y=x be included? (relevant only for continuous)
    
    # Create title if not supplied
    if(is.null(useTitle)) useTitle <- paste0("Predicting ", trueCol)

    # Function auto-round returns vector as-is when rndTo is NULL and auto-rounds when rndTo is -1L
    df <- df %>%
        mutate(across(all_of(c(trueCol, predCol)), 
                      .fns=function(x) autoRound(x, rndTo=rndTo, rndBucketsAuto=rndBucketsAuto, nSig=nSig)
                      )
               )
    
    # Create base plot (applicable to categorical or continuous variables)
    # Use x as true and y as predicted, for more meaningful geom_smooth() if continuous
    # Flip coordinates if categorical
    p1 <- df %>%
        group_by(across(all_of(c(trueCol, predCol)))) %>%
        summarize(n=n(), .groups="drop") %>%
        ggplot(aes(y=get(predCol), x=get(trueCol))) + 
        labs(y="Predicted", x="Actual", title=useTitle, subtitle=useSub)
        
    # Update plot as appropriate
    if(isTRUE(plotCont)) {
        p1 <- p1 +
            geom_point(aes(size=n), alpha=0.5) + 
            scale_size_continuous("# Obs") +
            geom_smooth(aes(weight=n), method="lm")
        if(isTRUE(refXY)) p1 <- p1 + geom_abline(slope=1, intercept=0, lty=2, color="red")
    } else {
        p1 <- p1 + 
            geom_tile(aes(fill=n)) + 
            geom_text(aes(label=n), size=2.5) +
            coord_flip() +
            scale_fill_continuous("", low="white", high="green")
    }
    
    # Output plot
    print(p1)
    
}

runFullRF <- function(dfTrain, 
                      yVar, 
                      xVars, 
                      dfTest=dfTrain,
                      useLabel="test data",
                      useSub=NULL, 
                      isContVar=FALSE,
                      rndTo=NULL,
                      rndBucketsAuto=100,
                      nSig=NULL,
                      refXY=FALSE,
                      makePlots=TRUE,
                      plotImp=makePlots,
                      plotConf=makePlots,
                      returnData=FALSE, 
                      ...
                      ) {
    
    # FUNCTION ARGUMENTS:
    # dfTrain: training data
    # yVar: dependent variable
    # xVars: column(s) containing independent variables
    # dfTest: test dataset for applying predictions
    # useLabel: label to be used for reporting accuracy
    # useSub: subtitle to be used for confusion chart (NULL means none)
    # isContVar: boolean, is the variable continuous? (default FALSE means categorical)
    # rndTo: every number in x should be rounded to the nearest rndTo
    #        NULL means no rounding (default)
    #        -1L means make an estimate based on data
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)    
    # refXY: boolean, should a reference line for y=x be included? (relevant only for continuous)
    # makePlots: boolean, should plots be created for variable importance and confusion matrix?
    # plotImp: boolean, should variable importance be plotted? (default is makePlots)
    # plotConf: boolean, should confusion matrix be plotted? (default is makePlots)
    # returnData: boolean, should data be returned?
    # ...: additional parameters to pass to runSimpleRF(), which are then passed to ranger::ranger()

    # 1. Run random forest using impurity for importance
    rf <- runSimpleRF(df=dfTrain, yVar=yVar, xVars=xVars, importance="impurity", ...)

    # 2. Create, and optionally plot, variable importance
    rfImp <- plotRFImportance(rf, plotData=plotImp, returnData=TRUE)

    # 3. Predict on test dataset
    tstPred <- predictRF(rf=rf, df=dfTest)

    # 4. Report on accuracy (updated for continuous or categorical)
    rfAcc <- reportAccuracy(tstPred, 
                            trueCol=yVar, 
                            rndReport=3, 
                            useLabel=useLabel, 
                            reportR2=isTRUE(isContVar),
                            returnAcc=TRUE
                            )

    # 5. Plot confusion data (updated for continuous vs. categorical) if requested
    if(isTRUE(plotConf)) {
        plotConfusion(tstPred, 
                      trueCol=yVar, 
                      useSub=useSub, 
                      plotCont=isTRUE(isContVar), 
                      rndTo=rndTo, 
                      rndBucketsAuto=rndBucketsAuto,
                      nSig=nSig,
                      refXY=refXY
                      )
    }
    
    #6. Return data if requested
    if(isTRUE(returnData)) return(list(rf=rf, rfImp=rfImp, tstPred=tstPred, rfAcc=rfAcc))
    
}

runPartialImportanceRF <- function(dfTrain, 
                                   yVar, 
                                   dfTest,
                                   impDB=dfImp,
                                   nImp=+Inf,
                                   otherX=c(),
                                   isContVar=TRUE, 
                                   useLabel=keyLabel, 
                                   useSub=stringr::str_to_sentence(keyLabel), 
                                   rndTo=NULL,
                                   rndBucketsAuto=50,
                                   nSig=NULL,
                                   refXY=FALSE,
                                   makePlots=FALSE, 
                                   returnElem=c("rfImp", "rfAcc")
                                   ) {
    
    # FUNCTION ARGUMENTS
    # dfTrain: training data
    # yVar: y variable in dfTrain
    # dfTest: test data
    # impDB: tibble containing variable importance by dependent variable
    # nImp: use the top nImp variables by variable importance
    # otherX: include these additional x variables
    # isContVar: boolean, is this a continuous variable (regression)? FALSE means classification
    # useLabel: label for description
    # useSub: label for plot
    # rndTo: controls the rounding parameter for plots, passed to runFullRF 
    #        (NULL means no rounding)
    #        -1L means make an estimate based on underlying data
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)    
    # refXY: controls the reference line parameter for plots, passed to runFullRF
    # makePlots: boolean, should plots be created?
    # returnElem: character vector of list elements to be returned

    runFullRF(dfTrain=dfTrain, 
              yVar=yVar, 
              xVars=unique(c(impDB %>% filter(n<=nImp, src==yVar) %>% pull(metric), otherX)), 
              dfTest=dfTest, 
              isContVar = isContVar, 
              useLabel=useLabel, 
              useSub=useSub, 
              rndTo=rndTo,
              rndBucketsAuto=rndBucketsAuto,
              nSig=nSig,
              refXY=refXY,
              makePlots=makePlots,
              returnData=TRUE
              )[returnElem]
    
}

autoRound <- function(x, rndTo=-1L, rndBucketsAuto=100, nSig=NULL) {

    # FUNCTION ARGUMENTS
    # x: vector to be rounded
    # rndTo: every number in x should be rounded to the nearest rndTo
    #        NULL means no rounding
    #        -1L means make an estimate based on data (default)
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)
    
    # If rndTo is passed as NULL, return x as-is
    if(is.null(rndTo)) return(x)
    
    # If rndTo is passed as -1L, make an estimate for rndTo
    if(isTRUE(all.equal(-1L, rndTo))) {
        # Get the number of unique values in x
        nUq <- length(unique(x))
        # If the number of unique values is no more than 150% of rndToBucketsAuto, return as-is
        if(nUq <= 1.5*rndBucketsAuto) return(x)
        # Otherwise, calculate a value for rndTo
        rndTo <- diff(range(x)) / rndBucketsAuto
        # Truncate to requested number of significant digits
        if(!is.null(nSig)) rndTo <- signif(rndTo, digits=nSig)
    }
    
    # Return the rounded vector if it was not already returned
    return(round(x/rndTo)*rndTo)

}


autoPartialImportance <- function(dfTrain, 
                                  dfTest, 
                                  yVar, 
                                  isContVar,
                                  impDB=dfImp,
                                  impNums=c(1:10, 16, 25, nrow(filter(dfImp, src==yVar)))
                                  ) {
    
    # FUNCTION ARGUMENTS:
    # dfTrain: training data
    # dfTest: test (holdout) data
    # yVar: dependent variable
    # isContVar: boolean, is this a contnuous variable (R-2) or categorical variable (accuracy)?
    # impDB: tibble containing sorted variable importances by predictor
    # impNums: vector of number of variables to run (each element in vector run)
    
    # Accuracy on holdout data
    tblRPI <- tibble::tibble(nImp=impNums, 
                             rfAcc=sapply(impNums, 
                                          FUN=function(x) {y <- runPartialImportanceRF(dfTrain=dfTrain, 
                                                                                       yVar=yVar, 
                                                                                       dfTest=dfTest, 
                                                                                       isContVar=isContVar, 
                                                                                       impDB=impDB, 
                                                                                       nImp=x, 
                                                                                       makePlots=FALSE
                                                                                       )[["rfAcc"]]
                                                           if(isTRUE(isContVar)) y <- y["r2"]
                                                           y
                                                           }
                                          )
                             )
    print(tblRPI)

    # Plot of holdout accuracy/r-squared vs. number of variables
    # if(isTRUE(isContVar)) tblRPI <- tblRPI %>% mutate(rfAcc=r2)
    if(isTRUE(isContVar)) prtDesc <- "R-squared" else prtDesc <- "Accuracy"
    p1 <- tblRPI %>%
        select(nImp, rfAcc) %>%
        bind_rows(tibble::tibble(nImp=0, rfAcc=0)) %>%
        ggplot(aes(x=nImp, y=rfAcc)) + 
        geom_line() + 
        geom_point() + 
        labs(title=paste0(prtDesc, " on holdout data vs. number of predictors"), 
             subtitle=paste0("Predicting ", yVar),
             y=paste0(prtDesc, " on holdout data"), 
             x="# Predictors (selected in order of variable importance in full model)"
             ) + 
        lims(y=c(0, 1)) + 
        geom_hline(data=~filter(., rfAcc==max(rfAcc)), aes(yintercept=rfAcc), lty=2)
    print(p1)
    
    return(tblRPI)
    
}


runNextBestPredictor <- function(varsRun, 
                                 xFix, 
                                 yVar, 
                                 isContVar,
                                 dfTrain,
                                 dfTest=dfTrain, 
                                 useLabel="predictions based on training data applied to holdout dataset",
                                 useSub=stringr::str_to_sentence(keyLabel_v3), 
                                 makePlots=FALSE
                                 ) {
    
    # FUNCTION ARGUMENTS:
    # varsRun: variables to be run as potential next-best predictors
    # xFix: variables that are already included in every test of next-best
    # yVar: dependent variable of interest
    # isContVar: boolean, is yvar continuous?
    # dfTrain: training data
    # dfTest: test data
    # useLabel: descriptive label
    # useSub: subtitle description
    # makePlots: boolean, should plots be created for each predictor run?
    
    vecAcc <- sapply(varsRun, FUN=function(x) {
        y <- runFullRF(dfTrain=dfTrain, 
                  yVar=yVar, 
                  xVars=c(xFix, x),
                  dfTest=dfTest, 
                  useLabel=useLabel, 
                  useSub=useSub,
                  isContVar=isContVar,
                  makePlots=makePlots,
                  returnData=TRUE
                  )[["rfAcc"]]
        if(isTRUE(isContVar)) y[["r2"]] else y
        }
        )

    vecAcc %>% 
        as.data.frame() %>% 
        purrr::set_names("rfAcc") %>% 
        rownames_to_column("pred") %>% 
        tibble::tibble() %>%
        arrange(desc(rfAcc)) %>%
        print(n=40)
    
    vecAcc

}


getNextBestVar <- function(x, returnTbl=FALSE, n=if(isTRUE(returnTbl)) +Inf else 1) {
    
    # FUNCTION ARGUMENTS:
    # x: named vector of accuracy or r-squared
    # returnTbl: boolean, if TRUE convert to tibble and return, if FALSE return vector of top-n predictors 
    # n: number of predictrs to return (+Inf will return the full tibble or vector)
    
    tbl <- vecToTibble(x, colNameName="pred") %>%
        arrange(-value) %>%
        slice_head(n=n)
    if(isTRUE(returnTbl)) return(tbl)
    else return(tbl %>% pull(pred))
    
}


newCityPredict <- function(rf, 
                           dfTest, 
                           trueCol, 
                           isContVar=FALSE,
                           reportR2=isTRUE(isContVar), 
                           plotCont=isTRUE(isContVar), 
                           reportAcc=TRUE, 
                           rndReport=2, 
                           useLabel="requested data",
                           useTitle=NULL,
                           useSub=NULL, 
                           rndTo=NULL,
                           rndBucketsAuto=100,
                           nSig=NULL,
                           refXY=FALSE, 
                           returnData=TRUE
                           ) {
    
    # FUNCTION ARGUMENTS:
    # rf: The existing "ranger" model OR a list containing element "rf" that has the existing "ranger" model
    # dfTest: the new dataset for predictions
    # trueCol: column containing true value
    # isContVar: boolean, is the variable continuous? (default FALSE means categorical)
    # reportR2: boolean, should accuracy be calculated as R-squared?
    #           (FALSE measures as categorical)
    # plotCont: boolean, should plotting assume continuous variables?
    #           (FALSE assumes confusion plot for categorical variables)
    # reportAcc: boolean, should accuracy be reported (printed to output)?
    # rndReport: number of significant digits for reporting (will be converted to percentage first)
    # useLabel: label for data to be used in reporting
    # useTitle: title to be used for chart (NULL means create from trueCol)
    # useSub: subtitle to be used for chart (NULL means none)
    # rndTo: every number in x should be rounded to the nearest rndTo
    #        NULL means no rounding (default)
    #        -1L means make an estimate based on data
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)
    # refXY: boolean, should a reference line for y=x be included? (relevant only for continuous)
    # returnData: boolean, should a list be returned containing tstPred and rfAcc?
    
    # Get the ranger data
    if(!("ranger" %in% class(rf))) {
        if(!("rf" %in% names(rf))) {
            stop("\nERROR: rf must be of class 'ranger' OR a list with element 'rf' that is of class 'ranger")
        }
        rf <- rf[["rf"]]
    }
    if(!("ranger" %in% class(rf)))
        stop("\nERROR: rf must be of class 'ranger' OR a list with element 'rf' that is of class 'ranger")
    
    # Predict on new dataset
    tstPred <- predictRF(rf=rf, df=dfTest)

    # Report on accuracy
    rfAcc <- reportAccuracy(tstPred, 
                            trueCol=trueCol, 
                            reportAcc=reportAcc,
                            rndReport=rndReport, 
                            useLabel=useLabel, 
                            reportR2=reportR2,
                            returnAcc=TRUE
                            )

    # Plot confusion data
    plotConfusion(tstPred, 
                  trueCol=trueCol, 
                  useTitle=useTitle,
                  useSub=useSub, 
                  plotCont=plotCont, 
                  rndTo=rndTo,
                  rndBucketsAuto=rndBucketsAuto,
                  nSig=nSig,
                  refXY=refXY
                  )
    
    # Return data if requested
    if(isTRUE(returnData)) return(list(tstPred=tstPred, rfAcc=rfAcc))
    
}

Key mapping tables for available metrics are also copied:

hourlyMetrics <- "temperature_2m,relativehumidity_2m,dewpoint_2m,apparent_temperature,pressure_msl,surface_pressure,precipitation,rain,snowfall,cloudcover,cloudcover_low,cloudcover_mid,cloudcover_high,shortwave_radiation,direct_radiation,direct_normal_irradiance,diffuse_radiation,windspeed_10m,windspeed_100m,winddirection_10m,winddirection_100m,windgusts_10m,et0_fao_evapotranspiration,weathercode,vapor_pressure_deficit,soil_temperature_0_to_7cm,soil_temperature_7_to_28cm,soil_temperature_28_to_100cm,soil_temperature_100_to_255cm,soil_moisture_0_to_7cm,soil_moisture_7_to_28cm,soil_moisture_28_to_100cm,soil_moisture_100_to_255cm"
dailyMetrics <- "weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,precipitation_sum,rain_sum,snowfall_sum,precipitation_hours,sunrise,sunset,windspeed_10m_max,windgusts_10m_max,winddirection_10m_dominant,shortwave_radiation_sum,et0_fao_evapotranspiration"

hourlyDescription <- "Air temperature at 2 meters above ground\nRelative humidity at 2 meters above ground\nDew point temperature at 2 meters above ground\nApparent temperature is the perceived feels-like temperature combining wind chill factor, relative humidity and solar radiation\nAtmospheric air pressure reduced to mean sea level (msl) or pressure at surface. Typically pressure on mean sea level is used in meteorology. Surface pressure gets lower with increasing elevation.\nAtmospheric air pressure reduced to mean sea level (msl) or pressure at surface. Typically pressure on mean sea level is used in meteorology. Surface pressure gets lower with increasing elevation.\nTotal precipitation (rain, showers, snow) sum of the preceding hour. Data is stored with a 0.1 mm precision. If precipitation data is summed up to monthly sums, there might be small inconsistencies with the total precipitation amount.\nOnly liquid precipitation of the preceding hour including local showers and rain from large scale systems.\nSnowfall amount of the preceding hour in centimeters. For the water equivalent in millimeter, divide by 7. E.g. 7 cm snow = 10 mm precipitation water equivalent\nTotal cloud cover as an area fraction\nLow level clouds and fog up to 2 km altitude\nMid level clouds from 2 to 6 km altitude\nHigh level clouds from 6 km altitude\nShortwave solar radiation as average of the preceding hour. This is equal to the total global horizontal irradiation\nDirect solar radiation as average of the preceding hour on the horizontal plane and the normal plane (perpendicular to the sun)\nDirect solar radiation as average of the preceding hour on the horizontal plane and the normal plane (perpendicular to the sun)\nDiffuse solar radiation as average of the preceding hour\nWind speed at 10 or 100 meters above ground. Wind speed on 10 meters is the standard level.\nWind speed at 10 or 100 meters above ground. Wind speed on 10 meters is the standard level.\nWind direction at 10 or 100 meters above ground\nWind direction at 10 or 100 meters above ground\nGusts at 10 meters above ground of the indicated hour. Wind gusts in CERRA are defined as the maximum wind gusts of the preceding hour. Please consult the ECMWF IFS documentation for more information on how wind gusts are parameterized in weather models.\nET0 Reference Evapotranspiration of a well watered grass field. Based on FAO-56 Penman-Monteith equations ET0 is calculated from temperature, wind speed, humidity and solar radiation. Unlimited soil water is assumed. ET0 is commonly used to estimate the required irrigation for plants.\nWeather condition as a numeric code. Follow WMO weather interpretation codes. See table below for details. Weather code is calculated from cloud cover analysis, precipitation and snowfall. As barely no information about atmospheric stability is available, estimation about thunderstorms is not possible.\nVapor Pressure Deificit (VPD) in kilopascal (kPa). For high VPD (>1.6), water transpiration of plants increases. For low VPD (<0.4), transpiration decreases\nAverage temperature of different soil levels below ground.\nAverage temperature of different soil levels below ground.\nAverage temperature of different soil levels below ground.\nAverage temperature of different soil levels below ground.\nAverage soil water content as volumetric mixing ratio at 0-7, 7-28, 28-100 and 100-255 cm depths.\nAverage soil water content as volumetric mixing ratio at 0-7, 7-28, 28-100 and 100-255 cm depths.\nAverage soil water content as volumetric mixing ratio at 0-7, 7-28, 28-100 and 100-255 cm depths.\nAverage soil water content as volumetric mixing ratio at 0-7, 7-28, 28-100 and 100-255 cm depths."
dailyDescription <- "The most severe weather condition on a given day\nMaximum and minimum daily air temperature at 2 meters above ground\nMaximum and minimum daily air temperature at 2 meters above ground\nMaximum and minimum daily apparent temperature\nMaximum and minimum daily apparent temperature\nSum of daily precipitation (including rain, showers and snowfall)\nSum of daily rain\nSum of daily snowfall\nThe number of hours with rain\nSun rise and set times\nSun rise and set times\nMaximum wind speed and gusts on a day\nMaximum wind speed and gusts on a day\nDominant wind direction\nThe sum of solar radiaion on a given day in Megajoules\nDaily sum of ET0 Reference Evapotranspiration of a well watered grass field"

# Create tibble for hourly metrics
tblMetricsHourly <- tibble::tibble(metric=hourlyMetrics %>% str_split_1(","), 
                                   description=hourlyDescription %>% str_split_1("\n")
                                   )
tblMetricsHourly %>% 
    print(n=50)
## # A tibble: 33 × 2
##    metric                        description                                    
##    <chr>                         <chr>                                          
##  1 temperature_2m                Air temperature at 2 meters above ground       
##  2 relativehumidity_2m           Relative humidity at 2 meters above ground     
##  3 dewpoint_2m                   Dew point temperature at 2 meters above ground 
##  4 apparent_temperature          Apparent temperature is the perceived feels-li…
##  5 pressure_msl                  Atmospheric air pressure reduced to mean sea l…
##  6 surface_pressure              Atmospheric air pressure reduced to mean sea l…
##  7 precipitation                 Total precipitation (rain, showers, snow) sum …
##  8 rain                          Only liquid precipitation of the preceding hou…
##  9 snowfall                      Snowfall amount of the preceding hour in centi…
## 10 cloudcover                    Total cloud cover as an area fraction          
## 11 cloudcover_low                Low level clouds and fog up to 2 km altitude   
## 12 cloudcover_mid                Mid level clouds from 2 to 6 km altitude       
## 13 cloudcover_high               High level clouds from 6 km altitude           
## 14 shortwave_radiation           Shortwave solar radiation as average of the pr…
## 15 direct_radiation              Direct solar radiation as average of the prece…
## 16 direct_normal_irradiance      Direct solar radiation as average of the prece…
## 17 diffuse_radiation             Diffuse solar radiation as average of the prec…
## 18 windspeed_10m                 Wind speed at 10 or 100 meters above ground. W…
## 19 windspeed_100m                Wind speed at 10 or 100 meters above ground. W…
## 20 winddirection_10m             Wind direction at 10 or 100 meters above ground
## 21 winddirection_100m            Wind direction at 10 or 100 meters above ground
## 22 windgusts_10m                 Gusts at 10 meters above ground of the indicat…
## 23 et0_fao_evapotranspiration    ET0 Reference Evapotranspiration of a well wat…
## 24 weathercode                   Weather condition as a numeric code. Follow WM…
## 25 vapor_pressure_deficit        Vapor Pressure Deificit (VPD) in kilopascal (k…
## 26 soil_temperature_0_to_7cm     Average temperature of different soil levels b…
## 27 soil_temperature_7_to_28cm    Average temperature of different soil levels b…
## 28 soil_temperature_28_to_100cm  Average temperature of different soil levels b…
## 29 soil_temperature_100_to_255cm Average temperature of different soil levels b…
## 30 soil_moisture_0_to_7cm        Average soil water content as volumetric mixin…
## 31 soil_moisture_7_to_28cm       Average soil water content as volumetric mixin…
## 32 soil_moisture_28_to_100cm     Average soil water content as volumetric mixin…
## 33 soil_moisture_100_to_255cm    Average soil water content as volumetric mixin…
# Create tibble for daily metrics
tblMetricsDaily <- tibble::tibble(metric=dailyMetrics %>% str_split_1(","), 
                                  description=dailyDescription %>% str_split_1("\n")
                                   )
tblMetricsDaily
## # A tibble: 16 × 2
##    metric                     description                                       
##    <chr>                      <chr>                                             
##  1 weathercode                The most severe weather condition on a given day  
##  2 temperature_2m_max         Maximum and minimum daily air temperature at 2 me…
##  3 temperature_2m_min         Maximum and minimum daily air temperature at 2 me…
##  4 apparent_temperature_max   Maximum and minimum daily apparent temperature    
##  5 apparent_temperature_min   Maximum and minimum daily apparent temperature    
##  6 precipitation_sum          Sum of daily precipitation (including rain, showe…
##  7 rain_sum                   Sum of daily rain                                 
##  8 snowfall_sum               Sum of daily snowfall                             
##  9 precipitation_hours        The number of hours with rain                     
## 10 sunrise                    Sun rise and set times                            
## 11 sunset                     Sun rise and set times                            
## 12 windspeed_10m_max          Maximum wind speed and gusts on a day             
## 13 windgusts_10m_max          Maximum wind speed and gusts on a day             
## 14 winddirection_10m_dominant Dominant wind direction                           
## 15 shortwave_radiation_sum    The sum of solar radiaion on a given day in Megaj…
## 16 et0_fao_evapotranspiration Daily sum of ET0 Reference Evapotranspiration of …

A function is written to process saved data for later use:

formatOpenMeteoJSON <- function(x, 
                                glimpseData=TRUE, 
                                addVars=FALSE, 
                                addExtract="tblHourly", 
                                showStats=addVars
                                ) {
    
    # FUNCTION ARGUMENTS:
    # x: Saved json file for passage to readOpenMeteoJSON
    # glimpseData: boolean, should a glimpse of the file and metadata be shown?
    # addVars: boolean, should variables be added for later processing?
    # addExtract: list elemented to be extracted (relevant only for addVars=TRUE)
    # showStats: boolean, should counts of key elements be shown (relevant only for addVars=TRUE)

    # Read file
    lst <- readOpenMeteoJSON(x)
    
    # Show a glimpse if requested
    if(isTRUE(glimpseData)) {
        print(lst)
        prettyOpenMeteoMeta(lst)
    }
    
    # If no variables to be added, return the file
    if(!isTRUE(addVars)) return(lst)
    
    # Add statistics
    df <- lst[[addExtract]] %>%
        mutate(year=year(date), 
               month=factor(month.abb[lubridate::month(date)], levels=month.abb), 
               hour=lubridate::hour(time), 
               fct_hour=factor(hour), 
               tod=ifelse(hour>=7 & hour<=18, "Day", "Night"), 
               doy=yday(date),
               season=case_when(month %in% c("Mar", "Apr", "May") ~ "Spring", 
                                month %in% c("Jun", "Jul", "Aug") ~ "Summer", 
                                month %in% c("Sep", "Oct", "Nov") ~ "Fall", 
                                month %in% c("Dec", "Jan", "Feb") ~ "Winter", 
                                TRUE~"typo"
                                ), 
               todSeason=paste0(season, "-", tod), 
               tod=factor(tod, levels=c("Day", "Night")), 
               season=factor(season, levels=c("Spring", "Summer", "Fall", "Winter")), 
               todSeason=factor(todSeason, 
                                levels=paste0(rep(c("Spring", "Summer", "Fall", "Winter"), each=2), 
                                              "-", 
                                              c("Day", "Night")
                                              )
                                ),
               across(where(is.numeric), .fns=function(x) round(100*percent_rank(x)), .names="pct_{.col}")
               )
    
    # Show counts if requested
    if(isTRUE(showStats)) {
        # Glimpse file
        glimpse(df)
        # Counts of day-of-year/month
        p1 <- df %>% 
            count(doy, month) %>% 
            ggplot(aes(y=doy, x=month)) + 
            geom_boxplot(aes(weight=n), fill="lightblue") + 
            labs(title="Observations by day-of-year and month", x=NULL, y="Day of Year")
        print(p1)
        # Counts of year/month
        p2 <- df %>% 
            count(year, month) %>% 
            ggplot(aes(y=factor(year), x=month)) + 
            geom_tile(aes(fill=n)) + 
            geom_text(aes(label=n), size=3) + 
            scale_fill_continuous("# Records", low="white", high="green") + 
            labs(title="Records by year and month", x=NULL, y=NULL)
        print(p2)
        # Counts of todSeason-season-tod, hour-fct_hour-tod, and month-season
        df %>% count(todSeason, season, tod) %>% print()
        df %>% count(hour, fct_hour, tod) %>% print(n=30)
        df %>% count(month, season) %>% print()
    }
    
    # Return the file
    df
    
}

Core daily datasets are loaded:

# Read daily JSON file
nycOMDaily <- formatOpenMeteoJSON("testOM_daily_nyc.json")
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, daily_units, daily 
## 
## $tblDaily
## # A tibble: 4,914 × 18
##    date       time       weathercode temperature_2m_max temperature_2m_min
##    <date>     <chr>            <int>              <dbl>              <dbl>
##  1 2010-01-01 2010-01-01          73                5                 -1.4
##  2 2010-01-02 2010-01-02          71               -0.6               -9.2
##  3 2010-01-03 2010-01-03          71               -4.8              -10  
##  4 2010-01-04 2010-01-04           1               -0.8               -7.3
##  5 2010-01-05 2010-01-05           1               -0.2               -7.3
##  6 2010-01-06 2010-01-06           2                1.1               -5.3
##  7 2010-01-07 2010-01-07           2                3.6               -3.7
##  8 2010-01-08 2010-01-08          71                1.9               -5.7
##  9 2010-01-09 2010-01-09           0               -1.4               -7.7
## 10 2010-01-10 2010-01-10           0               -1.7              -10.3
## # ℹ 4,904 more rows
## # ℹ 13 more variables: apparent_temperature_max <dbl>,
## #   apparent_temperature_min <dbl>, precipitation_sum <dbl>, rain_sum <dbl>,
## #   snowfall_sum <dbl>, precipitation_hours <dbl>, sunrise <chr>, sunset <chr>,
## #   windspeed_10m_max <dbl>, windgusts_10m_max <dbl>,
## #   winddirection_10m_dominant <int>, shortwave_radiation_sum <dbl>,
## #   et0_fao_evapotranspiration <dbl>
## 
## $tblHourly
## NULL
## 
## $tblUnits
## # A tibble: 17 × 4
##    metricType  name                       value      description                
##    <chr>       <chr>                      <chr>      <chr>                      
##  1 daily_units time                       "iso8601"  <NA>                       
##  2 daily_units weathercode                "wmo code" The most severe weather co…
##  3 daily_units temperature_2m_max         "deg C"    Maximum and minimum daily …
##  4 daily_units temperature_2m_min         "deg C"    Maximum and minimum daily …
##  5 daily_units apparent_temperature_max   "deg C"    Maximum and minimum daily …
##  6 daily_units apparent_temperature_min   "deg C"    Maximum and minimum daily …
##  7 daily_units precipitation_sum          "mm"       Sum of daily precipitation…
##  8 daily_units rain_sum                   "mm"       Sum of daily rain          
##  9 daily_units snowfall_sum               "cm"       Sum of daily snowfall      
## 10 daily_units precipitation_hours        "h"        The number of hours with r…
## 11 daily_units sunrise                    "iso8601"  Sun rise and set times     
## 12 daily_units sunset                     "iso8601"  Sun rise and set times     
## 13 daily_units windspeed_10m_max          "km/h"     Maximum wind speed and gus…
## 14 daily_units windgusts_10m_max          "km/h"     Maximum wind speed and gus…
## 15 daily_units winddirection_10m_dominant "deg "     Dominant wind direction    
## 16 daily_units shortwave_radiation_sum    "MJ/m²"    The sum of solar radiaion …
## 17 daily_units et0_fao_evapotranspiration "mm"       Daily sum of ET0 Reference…
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone        
##      <dbl>     <dbl>             <dbl>              <int> <chr>           
## 1     40.7     -73.9              101.             -14400 America/New_York
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 40.7
## longitude: -73.9
## generationtime_ms: 100.914
## utc_offset_seconds: -14400
## timezone: America/New_York
## timezone_abbreviation: EDT
## elevation: 36
laxOMDaily <- formatOpenMeteoJSON("testOM_daily_lax.json")
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, daily_units, daily 
## 
## $tblDaily
## # A tibble: 5,113 × 18
##    date       time       weathercode temperature_2m_max temperature_2m_min
##    <date>     <chr>            <int>              <dbl>              <dbl>
##  1 2010-01-01 2010-01-01           2               20.1                4.7
##  2 2010-01-02 2010-01-02           1               23.2                6.7
##  3 2010-01-03 2010-01-03           1               23                  6.5
##  4 2010-01-04 2010-01-04           2               22.1                6.5
##  5 2010-01-05 2010-01-05           1               22.9                5  
##  6 2010-01-06 2010-01-06           2               23.2                7.7
##  7 2010-01-07 2010-01-07           1               23.3                5.2
##  8 2010-01-08 2010-01-08           1               22.8                8.4
##  9 2010-01-09 2010-01-09           2               21.5                7.2
## 10 2010-01-10 2010-01-10           1               24                  7.5
## # ℹ 5,103 more rows
## # ℹ 13 more variables: apparent_temperature_max <dbl>,
## #   apparent_temperature_min <dbl>, precipitation_sum <dbl>, rain_sum <dbl>,
## #   snowfall_sum <dbl>, precipitation_hours <dbl>, sunrise <chr>, sunset <chr>,
## #   windspeed_10m_max <dbl>, windgusts_10m_max <dbl>,
## #   winddirection_10m_dominant <int>, shortwave_radiation_sum <dbl>,
## #   et0_fao_evapotranspiration <dbl>
## 
## $tblHourly
## NULL
## 
## $tblUnits
## # A tibble: 17 × 4
##    metricType  name                       value      description                
##    <chr>       <chr>                      <chr>      <chr>                      
##  1 daily_units time                       "iso8601"  <NA>                       
##  2 daily_units weathercode                "wmo code" The most severe weather co…
##  3 daily_units temperature_2m_max         "deg C"    Maximum and minimum daily …
##  4 daily_units temperature_2m_min         "deg C"    Maximum and minimum daily …
##  5 daily_units apparent_temperature_max   "deg C"    Maximum and minimum daily …
##  6 daily_units apparent_temperature_min   "deg C"    Maximum and minimum daily …
##  7 daily_units precipitation_sum          "mm"       Sum of daily precipitation…
##  8 daily_units rain_sum                   "mm"       Sum of daily rain          
##  9 daily_units snowfall_sum               "cm"       Sum of daily snowfall      
## 10 daily_units precipitation_hours        "h"        The number of hours with r…
## 11 daily_units sunrise                    "iso8601"  Sun rise and set times     
## 12 daily_units sunset                     "iso8601"  Sun rise and set times     
## 13 daily_units windspeed_10m_max          "km/h"     Maximum wind speed and gus…
## 14 daily_units windgusts_10m_max          "km/h"     Maximum wind speed and gus…
## 15 daily_units winddirection_10m_dominant "deg "     Dominant wind direction    
## 16 daily_units shortwave_radiation_sum    "MJ/m²"    The sum of solar radiaion …
## 17 daily_units et0_fao_evapotranspiration "mm"       Daily sum of ET0 Reference…
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone           
##      <dbl>     <dbl>             <dbl>              <int> <chr>              
## 1     34.1     -118.              58.9             -25200 America/Los_Angeles
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 34.13005
## longitude: -118.4981
## generationtime_ms: 58.85398
## utc_offset_seconds: -25200
## timezone: America/Los_Angeles
## timezone_abbreviation: PDT
## elevation: 333
chiOMDaily <- formatOpenMeteoJSON("testOM_daily_chi.json")
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, daily_units, daily 
## 
## $tblDaily
## # A tibble: 5,113 × 18
##    date       time       weathercode temperature_2m_max temperature_2m_min
##    <date>     <chr>            <int>              <dbl>              <dbl>
##  1 2010-01-01 2010-01-01           3               -8.6              -13.4
##  2 2010-01-02 2010-01-02           2              -10.4              -15.1
##  3 2010-01-03 2010-01-03           3               -7.9              -13.8
##  4 2010-01-04 2010-01-04           3               -6.9              -12.3
##  5 2010-01-05 2010-01-05           3               -4.8               -9.8
##  6 2010-01-06 2010-01-06          71               -4.9               -9  
##  7 2010-01-07 2010-01-07          73               -5.2               -8.5
##  8 2010-01-08 2010-01-08          73               -3                 -9.4
##  9 2010-01-09 2010-01-09           3               -5.8              -12.3
## 10 2010-01-10 2010-01-10           3               -8.8              -19.4
## # ℹ 5,103 more rows
## # ℹ 13 more variables: apparent_temperature_max <dbl>,
## #   apparent_temperature_min <dbl>, precipitation_sum <dbl>, rain_sum <dbl>,
## #   snowfall_sum <dbl>, precipitation_hours <dbl>, sunrise <chr>, sunset <chr>,
## #   windspeed_10m_max <dbl>, windgusts_10m_max <dbl>,
## #   winddirection_10m_dominant <int>, shortwave_radiation_sum <dbl>,
## #   et0_fao_evapotranspiration <dbl>
## 
## $tblHourly
## NULL
## 
## $tblUnits
## # A tibble: 17 × 4
##    metricType  name                       value      description                
##    <chr>       <chr>                      <chr>      <chr>                      
##  1 daily_units time                       "iso8601"  <NA>                       
##  2 daily_units weathercode                "wmo code" The most severe weather co…
##  3 daily_units temperature_2m_max         "deg C"    Maximum and minimum daily …
##  4 daily_units temperature_2m_min         "deg C"    Maximum and minimum daily …
##  5 daily_units apparent_temperature_max   "deg C"    Maximum and minimum daily …
##  6 daily_units apparent_temperature_min   "deg C"    Maximum and minimum daily …
##  7 daily_units precipitation_sum          "mm"       Sum of daily precipitation…
##  8 daily_units rain_sum                   "mm"       Sum of daily rain          
##  9 daily_units snowfall_sum               "cm"       Sum of daily snowfall      
## 10 daily_units precipitation_hours        "h"        The number of hours with r…
## 11 daily_units sunrise                    "iso8601"  Sun rise and set times     
## 12 daily_units sunset                     "iso8601"  Sun rise and set times     
## 13 daily_units windspeed_10m_max          "km/h"     Maximum wind speed and gus…
## 14 daily_units windgusts_10m_max          "km/h"     Maximum wind speed and gus…
## 15 daily_units winddirection_10m_dominant "deg "     Dominant wind direction    
## 16 daily_units shortwave_radiation_sum    "MJ/m²"    The sum of solar radiaion …
## 17 daily_units et0_fao_evapotranspiration "mm"       Daily sum of ET0 Reference…
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone       
##      <dbl>     <dbl>             <dbl>              <int> <chr>          
## 1     41.9     -87.6              59.4             -18000 America/Chicago
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 41.86292
## longitude: -87.64877
## generationtime_ms: 59.38601
## utc_offset_seconds: -18000
## timezone: America/Chicago
## timezone_abbreviation: CDT
## elevation: 180
houOMDaily <- formatOpenMeteoJSON("testOM_daily_hou.json")
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, daily_units, daily 
## 
## $tblDaily
## # A tibble: 5,113 × 18
##    date       time       weathercode temperature_2m_max temperature_2m_min
##    <date>     <chr>            <int>              <dbl>              <dbl>
##  1 2010-01-01 2010-01-01           3               11.8                3.9
##  2 2010-01-02 2010-01-02           1               12                  0.7
##  3 2010-01-03 2010-01-03           3               10                  4.4
##  4 2010-01-04 2010-01-04           3                7.6                1.8
##  5 2010-01-05 2010-01-05           0                8                 -1.9
##  6 2010-01-06 2010-01-06          51               12.7               -0.1
##  7 2010-01-07 2010-01-07          55               13.4               -0.2
##  8 2010-01-08 2010-01-08           2                0.8               -3  
##  9 2010-01-09 2010-01-09           0                4.4               -5.5
## 10 2010-01-10 2010-01-10           0                5.9               -4.6
## # ℹ 5,103 more rows
## # ℹ 13 more variables: apparent_temperature_max <dbl>,
## #   apparent_temperature_min <dbl>, precipitation_sum <dbl>, rain_sum <dbl>,
## #   snowfall_sum <dbl>, precipitation_hours <dbl>, sunrise <chr>, sunset <chr>,
## #   windspeed_10m_max <dbl>, windgusts_10m_max <dbl>,
## #   winddirection_10m_dominant <int>, shortwave_radiation_sum <dbl>,
## #   et0_fao_evapotranspiration <dbl>
## 
## $tblHourly
## NULL
## 
## $tblUnits
## # A tibble: 17 × 4
##    metricType  name                       value      description                
##    <chr>       <chr>                      <chr>      <chr>                      
##  1 daily_units time                       "iso8601"  <NA>                       
##  2 daily_units weathercode                "wmo code" The most severe weather co…
##  3 daily_units temperature_2m_max         "deg C"    Maximum and minimum daily …
##  4 daily_units temperature_2m_min         "deg C"    Maximum and minimum daily …
##  5 daily_units apparent_temperature_max   "deg C"    Maximum and minimum daily …
##  6 daily_units apparent_temperature_min   "deg C"    Maximum and minimum daily …
##  7 daily_units precipitation_sum          "mm"       Sum of daily precipitation…
##  8 daily_units rain_sum                   "mm"       Sum of daily rain          
##  9 daily_units snowfall_sum               "cm"       Sum of daily snowfall      
## 10 daily_units precipitation_hours        "h"        The number of hours with r…
## 11 daily_units sunrise                    "iso8601"  Sun rise and set times     
## 12 daily_units sunset                     "iso8601"  Sun rise and set times     
## 13 daily_units windspeed_10m_max          "km/h"     Maximum wind speed and gus…
## 14 daily_units windgusts_10m_max          "km/h"     Maximum wind speed and gus…
## 15 daily_units winddirection_10m_dominant "deg "     Dominant wind direction    
## 16 daily_units shortwave_radiation_sum    "MJ/m²"    The sum of solar radiaion …
## 17 daily_units et0_fao_evapotranspiration "mm"       Daily sum of ET0 Reference…
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone  
##      <dbl>     <dbl>             <dbl>              <int> <chr>     
## 1     29.8     -95.4              64.0             -18000 US/Central
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 29.77153
## longitude: -95.43555
## generationtime_ms: 63.96198
## utc_offset_seconds: -18000
## timezone: US/Central
## timezone_abbreviation: CDT
## elevation: 17

Processed hourly data for NYC and LA are loaded:

# Read hourly JSON file (NYC and LA)
nycTemp <- formatOpenMeteoJSON("testOM_hourly_nyc.json", addVars=TRUE)
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, hourly_units, hourly 
## 
## $tblDaily
## NULL
## 
## $tblHourly
## # A tibble: 117,936 × 37
##    time                date        hour temperature_2m relativehumidity_2m
##    <dttm>              <date>     <int>          <dbl>               <int>
##  1 2010-01-01 00:00:00 2010-01-01     0           -1.1                  95
##  2 2010-01-01 01:00:00 2010-01-01     1           -1                    96
##  3 2010-01-01 02:00:00 2010-01-01     2           -1                    96
##  4 2010-01-01 03:00:00 2010-01-01     3           -0.8                  97
##  5 2010-01-01 04:00:00 2010-01-01     4           -0.9                  97
##  6 2010-01-01 05:00:00 2010-01-01     5           -0.8                  97
##  7 2010-01-01 06:00:00 2010-01-01     6           -0.7                  97
##  8 2010-01-01 07:00:00 2010-01-01     7           -0.5                  97
##  9 2010-01-01 08:00:00 2010-01-01     8           -0.6                  97
## 10 2010-01-01 09:00:00 2010-01-01     9           -0.6                  97
## # ℹ 117,926 more rows
## # ℹ 32 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
## 
## $tblUnits
## # A tibble: 34 × 4
##    metricType   name                 value   description                        
##    <chr>        <chr>                <chr>   <chr>                              
##  1 hourly_units time                 iso8601 <NA>                               
##  2 hourly_units temperature_2m       deg C   Air temperature at 2 meters above …
##  3 hourly_units relativehumidity_2m  %       Relative humidity at 2 meters abov…
##  4 hourly_units dewpoint_2m          deg C   Dew point temperature at 2 meters …
##  5 hourly_units apparent_temperature deg C   Apparent temperature is the percei…
##  6 hourly_units pressure_msl         hPa     Atmospheric air pressure reduced t…
##  7 hourly_units surface_pressure     hPa     Atmospheric air pressure reduced t…
##  8 hourly_units precipitation        mm      Total precipitation (rain, showers…
##  9 hourly_units rain                 mm      Only liquid precipitation of the p…
## 10 hourly_units snowfall             cm      Snowfall amount of the preceding h…
## # ℹ 24 more rows
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone        
##      <dbl>     <dbl>             <dbl>              <int> <chr>           
## 1     40.7     -73.9              118.             -14400 America/New_York
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 40.7
## longitude: -73.9
## generationtime_ms: 118.0021
## utc_offset_seconds: -14400
## timezone: America/New_York
## timezone_abbreviation: EDT
## elevation: 36
## 
## Rows: 117,936
## Columns: 80
## $ time                              <dttm> 2010-01-01 00:00:00, 2010-01-01 01:…
## $ date                              <date> 2010-01-01, 2010-01-01, 2010-01-01,…
## $ hour                              <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ temperature_2m                    <dbl> -1.1, -1.0, -1.0, -0.8, -0.9, -0.8, …
## $ relativehumidity_2m               <int> 95, 96, 96, 97, 97, 97, 97, 97, 97, …
## $ dewpoint_2m                       <dbl> -1.7, -1.6, -1.6, -1.2, -1.3, -1.2, …
## $ apparent_temperature              <dbl> -3.9, -3.9, -3.9, -3.7, -3.7, -3.6, …
## $ pressure_msl                      <dbl> 1017.2, 1016.5, 1015.9, 1015.6, 1015…
## $ surface_pressure                  <dbl> 1012.6, 1011.9, 1011.3, 1011.0, 1011…
## $ precipitation                     <dbl> 0.5, 0.5, 0.4, 0.3, 0.1, 0.0, 0.0, 0…
## $ rain                              <dbl> 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.0, 0…
## $ snowfall                          <dbl> 0.35, 0.28, 0.21, 0.14, 0.07, 0.00, …
## $ cloudcover                        <int> 90, 93, 80, 68, 71, 100, 100, 100, 1…
## $ cloudcover_low                    <int> 2, 8, 3, 6, 15, 51, 99, 99, 96, 77, …
## $ cloudcover_mid                    <int> 98, 96, 99, 98, 95, 97, 98, 99, 94, …
## $ cloudcover_high                   <int> 97, 93, 59, 13, 0, 0, 0, 0, 0, 0, 0,…
## $ shortwave_radiation               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 53, 11…
## $ direct_radiation                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20…
## $ direct_normal_irradiance          <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0…
## $ diffuse_radiation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 41, 93…
## $ windspeed_10m                     <dbl> 3.1, 3.5, 3.3, 3.9, 3.5, 3.4, 0.0, 1…
## $ windspeed_100m                    <dbl> 3.8, 3.1, 3.8, 4.7, 6.4, 5.7, 1.4, 1…
## $ winddirection_10m                 <int> 339, 336, 347, 338, 336, 342, 180, 2…
## $ winddirection_100m                <int> 41, 21, 17, 356, 344, 342, 360, 217,…
## $ windgusts_10m                     <dbl> 9.0, 9.7, 10.1, 7.6, 7.6, 6.8, 5.4, …
## $ et0_fao_evapotranspiration        <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, …
## $ weathercode                       <int> 73, 73, 73, 71, 71, 3, 3, 3, 3, 3, 3…
## $ vapor_pressure_deficit            <dbl> 0.03, 0.02, 0.02, 0.02, 0.02, 0.02, …
## $ soil_temperature_0_to_7cm         <dbl> -0.7, -0.7, -0.7, -0.6, -0.6, -0.6, …
## $ soil_temperature_7_to_28cm        <dbl> 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0…
## $ soil_temperature_28_to_100cm      <dbl> 4.2, 4.2, 4.1, 4.1, 4.1, 4.1, 4.1, 4…
## $ soil_temperature_100_to_255cm     <dbl> 10.6, 10.6, 10.6, 10.6, 10.6, 10.6, …
## $ soil_moisture_0_to_7cm            <dbl> 0.373, 0.374, 0.376, 0.377, 0.377, 0…
## $ soil_moisture_7_to_28cm           <dbl> 0.377, 0.377, 0.377, 0.377, 0.377, 0…
## $ soil_moisture_28_to_100cm         <dbl> 0.413, 0.413, 0.413, 0.413, 0.413, 0…
## $ soil_moisture_100_to_255cm        <dbl> 0.412, 0.412, 0.412, 0.412, 0.412, 0…
## $ origTime                          <chr> "2010-01-01T00:00", "2010-01-01T01:0…
## $ year                              <dbl> 2010, 2010, 2010, 2010, 2010, 2010, …
## $ month                             <fct> Jan, Jan, Jan, Jan, Jan, Jan, Jan, J…
## $ fct_hour                          <fct> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ tod                               <fct> Night, Night, Night, Night, Night, N…
## $ doy                               <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season                            <fct> Winter, Winter, Winter, Winter, Wint…
## $ todSeason                         <fct> Winter-Night, Winter-Night, Winter-N…
## $ pct_hour                          <dbl> 0, 4, 8, 13, 17, 21, 25, 29, 33, 38,…
## $ pct_temperature_2m                <dbl> 10, 10, 10, 11, 11, 11, 11, 12, 11, …
## $ pct_relativehumidity_2m           <dbl> 92, 94, 94, 96, 96, 96, 96, 96, 96, …
## $ pct_dewpoint_2m                   <dbl> 23, 24, 24, 25, 25, 25, 25, 25, 25, …
## $ pct_apparent_temperature          <dbl> 15, 15, 15, 15, 15, 15, 17, 17, 16, …
## $ pct_pressure_msl                  <dbl> 53, 49, 46, 44, 44, 41, 38, 36, 37, …
## $ pct_surface_pressure              <dbl> 51, 47, 44, 42, 42, 39, 36, 35, 36, …
## $ pct_precipitation                 <dbl> 93, 93, 92, 90, 86, 0, 0, 0, 0, 0, 0…
## $ pct_rain                          <dbl> 0, 87, 87, 87, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_snowfall                      <dbl> 99, 99, 99, 99, 98, 0, 0, 0, 0, 0, 0…
## $ pct_cloudcover                    <dbl> 77, 79, 72, 67, 68, 81, 81, 81, 81, …
## $ pct_cloudcover_low                <dbl> 51, 60, 53, 58, 65, 77, 90, 90, 88, …
## $ pct_cloudcover_mid                <dbl> 90, 89, 92, 90, 88, 89, 90, 92, 87, …
## $ pct_cloudcover_high               <dbl> 81, 76, 63, 49, 0, 0, 0, 0, 0, 0, 0,…
## $ pct_shortwave_radiation           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 57, 6…
## $ pct_direct_radiation              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 62…
## $ pct_direct_normal_irradiance      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 61…
## $ pct_diffuse_radiation             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 58, 7…
## $ pct_windspeed_10m                 <dbl> 3, 4, 3, 5, 4, 4, 0, 1, 2, 5, 8, 8, …
## $ pct_windspeed_100m                <dbl> 2, 1, 2, 3, 6, 5, 0, 0, 4, 9, 9, 8, …
## $ pct_winddirection_10m             <dbl> 94, 93, 96, 94, 93, 95, 35, 43, 53, …
## $ pct_winddirection_100m            <dbl> 8, 4, 3, 99, 96, 95, 100, 46, 51, 61…
## $ pct_windgusts_10m                 <dbl> 3, 4, 5, 1, 1, 1, 0, 0, 0, 1, 2, 4, …
## $ pct_et0_fao_evapotranspiration    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 32, 4…
## $ pct_weathercode                   <dbl> 99, 99, 99, 98, 98, 69, 69, 69, 69, …
## $ pct_vapor_pressure_deficit        <dbl> 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 8, …
## $ pct_soil_temperature_0_to_7cm     <dbl> 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 9, 10,…
## $ pct_soil_temperature_7_to_28cm    <dbl> 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, …
## $ pct_soil_temperature_28_to_100cm  <dbl> 16, 16, 15, 15, 15, 15, 15, 15, 15, …
## $ pct_soil_temperature_100_to_255cm <dbl> 42, 42, 42, 42, 42, 42, 42, 42, 42, …
## $ pct_soil_moisture_0_to_7cm        <dbl> 70, 71, 73, 74, 74, 74, 74, 74, 73, …
## $ pct_soil_moisture_7_to_28cm       <dbl> 69, 69, 69, 69, 69, 68, 68, 68, 68, …
## $ pct_soil_moisture_28_to_100cm     <dbl> 96, 96, 96, 96, 96, 96, 96, 96, 96, …
## $ pct_soil_moisture_100_to_255cm    <dbl> 96, 96, 96, 96, 96, 96, 96, 96, 96, …
## $ pct_year                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_doy                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

## # A tibble: 8 × 4
##   todSeason    season tod       n
##   <fct>        <fct>  <fct> <int>
## 1 Spring-Day   Spring Day   15456
## 2 Spring-Night Spring Night 15456
## 3 Summer-Day   Summer Day   14532
## 4 Summer-Night Summer Night 14532
## 5 Fall-Day     Fall   Day   14196
## 6 Fall-Night   Fall   Night 14196
## 7 Winter-Day   Winter Day   14784
## 8 Winter-Night Winter Night 14784
## # A tibble: 24 × 4
##     hour fct_hour tod       n
##    <int> <fct>    <fct> <int>
##  1     0 0        Night  4914
##  2     1 1        Night  4914
##  3     2 2        Night  4914
##  4     3 3        Night  4914
##  5     4 4        Night  4914
##  6     5 5        Night  4914
##  7     6 6        Night  4914
##  8     7 7        Day    4914
##  9     8 8        Day    4914
## 10     9 9        Day    4914
## 11    10 10       Day    4914
## 12    11 11       Day    4914
## 13    12 12       Day    4914
## 14    13 13       Day    4914
## 15    14 14       Day    4914
## 16    15 15       Day    4914
## 17    16 16       Day    4914
## 18    17 17       Day    4914
## 19    18 18       Day    4914
## 20    19 19       Night  4914
## 21    20 20       Night  4914
## 22    21 21       Night  4914
## 23    22 22       Night  4914
## 24    23 23       Night  4914
## # A tibble: 12 × 3
##    month season     n
##    <fct> <fct>  <int>
##  1 Jan   Winter 10416
##  2 Feb   Winter  9480
##  3 Mar   Spring 10416
##  4 Apr   Spring 10080
##  5 May   Spring 10416
##  6 Jun   Summer  9720
##  7 Jul   Summer  9672
##  8 Aug   Summer  9672
##  9 Sep   Fall    9360
## 10 Oct   Fall    9672
## 11 Nov   Fall    9360
## 12 Dec   Winter  9672
laxTemp <- formatOpenMeteoJSON("testOM_hourly_lax.json", addVars=TRUE)
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, hourly_units, hourly 
## 
## $tblDaily
## NULL
## 
## $tblHourly
## # A tibble: 122,712 × 37
##    time                date        hour temperature_2m relativehumidity_2m
##    <dttm>              <date>     <int>          <dbl>               <int>
##  1 2010-01-01 00:00:00 2010-01-01     0            6.3                  60
##  2 2010-01-01 01:00:00 2010-01-01     1            5.7                  62
##  3 2010-01-01 02:00:00 2010-01-01     2            5.3                  63
##  4 2010-01-01 03:00:00 2010-01-01     3            5                    64
##  5 2010-01-01 04:00:00 2010-01-01     4            4.8                  64
##  6 2010-01-01 05:00:00 2010-01-01     5            4.7                  64
##  7 2010-01-01 06:00:00 2010-01-01     6            4.7                  64
##  8 2010-01-01 07:00:00 2010-01-01     7            4.8                  64
##  9 2010-01-01 08:00:00 2010-01-01     8            5.2                  64
## 10 2010-01-01 09:00:00 2010-01-01     9            6.3                  63
## # ℹ 122,702 more rows
## # ℹ 32 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
## 
## $tblUnits
## # A tibble: 34 × 4
##    metricType   name                 value   description                        
##    <chr>        <chr>                <chr>   <chr>                              
##  1 hourly_units time                 iso8601 <NA>                               
##  2 hourly_units temperature_2m       deg C   Air temperature at 2 meters above …
##  3 hourly_units relativehumidity_2m  %       Relative humidity at 2 meters abov…
##  4 hourly_units dewpoint_2m          deg C   Dew point temperature at 2 meters …
##  5 hourly_units apparent_temperature deg C   Apparent temperature is the percei…
##  6 hourly_units pressure_msl         hPa     Atmospheric air pressure reduced t…
##  7 hourly_units surface_pressure     hPa     Atmospheric air pressure reduced t…
##  8 hourly_units precipitation        mm      Total precipitation (rain, showers…
##  9 hourly_units rain                 mm      Only liquid precipitation of the p…
## 10 hourly_units snowfall             cm      Snowfall amount of the preceding h…
## # ℹ 24 more rows
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone           
##      <dbl>     <dbl>             <dbl>              <int> <chr>              
## 1     34.1     -118.             6196.             -25200 America/Los_Angeles
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 34.13005
## longitude: -118.4981
## generationtime_ms: 6196.377
## utc_offset_seconds: -25200
## timezone: America/Los_Angeles
## timezone_abbreviation: PDT
## elevation: 333
## 
## Rows: 122,712
## Columns: 80
## $ time                              <dttm> 2010-01-01 00:00:00, 2010-01-01 01:…
## $ date                              <date> 2010-01-01, 2010-01-01, 2010-01-01,…
## $ hour                              <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ temperature_2m                    <dbl> 6.3, 5.7, 5.3, 5.0, 4.8, 4.7, 4.7, 4…
## $ relativehumidity_2m               <int> 60, 62, 63, 64, 64, 64, 64, 64, 64, …
## $ dewpoint_2m                       <dbl> -0.9, -1.0, -1.2, -1.3, -1.4, -1.4, …
## $ apparent_temperature              <dbl> 2.9, 2.3, 1.8, 1.3, 1.0, 0.9, 0.9, 1…
## $ pressure_msl                      <dbl> 1026.5, 1026.1, 1025.7, 1025.7, 1024…
## $ surface_pressure                  <dbl> 985.7, 985.2, 984.8, 984.7, 983.9, 9…
## $ precipitation                     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ rain                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ snowfall                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover                        <int> 14, 21, 23, 29, 31, 30, 29, 30, 31, …
## $ cloudcover_low                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover_mid                    <int> 0, 0, 0, 0, 1, 0, 0, 0, 2, 3, 2, 6, …
## $ cloudcover_high                   <int> 48, 71, 78, 95, 100, 99, 98, 99, 100…
## $ shortwave_radiation               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 142, …
## $ direct_radiation                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 27, 16…
## $ direct_normal_irradiance          <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0…
## $ diffuse_radiation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 115, …
## $ windspeed_10m                     <dbl> 7.4, 7.8, 8.0, 9.7, 9.7, 10.1, 10.0,…
## $ windspeed_100m                    <dbl> 10.4, 10.6, 11.0, 14.9, 14.8, 14.6, …
## $ winddirection_10m                 <int> 14, 13, 10, 15, 15, 17, 15, 13, 13, …
## $ winddirection_100m                <int> 20, 24, 19, 20, 18, 20, 18, 18, 16, …
## $ windgusts_10m                     <dbl> 19.1, 19.1, 19.4, 19.8, 20.9, 21.6, …
## $ et0_fao_evapotranspiration        <dbl> 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, …
## $ weathercode                       <int> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ vapor_pressure_deficit            <dbl> 0.38, 0.35, 0.33, 0.31, 0.31, 0.31, …
## $ soil_temperature_0_to_7cm         <dbl> 7.0, 6.6, 6.2, 5.8, 5.6, 5.4, 5.3, 5…
## $ soil_temperature_7_to_28cm        <dbl> 10.8, 10.6, 10.3, 10.1, 9.9, 9.7, 9.…
## $ soil_temperature_28_to_100cm      <dbl> 12.9, 12.9, 12.9, 12.9, 12.9, 12.9, …
## $ soil_temperature_100_to_255cm     <dbl> 20.5, 20.5, 20.5, 20.5, 20.5, 20.5, …
## $ soil_moisture_0_to_7cm            <dbl> 0.205, 0.205, 0.205, 0.205, 0.205, 0…
## $ soil_moisture_7_to_28cm           <dbl> 0.251, 0.251, 0.251, 0.250, 0.250, 0…
## $ soil_moisture_28_to_100cm         <dbl> 0.168, 0.168, 0.168, 0.168, 0.168, 0…
## $ soil_moisture_100_to_255cm        <dbl> 0.165, 0.165, 0.165, 0.165, 0.165, 0…
## $ origTime                          <chr> "2010-01-01T00:00", "2010-01-01T01:0…
## $ year                              <dbl> 2010, 2010, 2010, 2010, 2010, 2010, …
## $ month                             <fct> Jan, Jan, Jan, Jan, Jan, Jan, Jan, J…
## $ fct_hour                          <fct> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ tod                               <fct> Night, Night, Night, Night, Night, N…
## $ doy                               <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season                            <fct> Winter, Winter, Winter, Winter, Wint…
## $ todSeason                         <fct> Winter-Night, Winter-Night, Winter-N…
## $ pct_hour                          <dbl> 0, 4, 8, 13, 17, 21, 25, 29, 33, 38,…
## $ pct_temperature_2m                <dbl> 4, 3, 3, 2, 2, 2, 2, 2, 3, 4, 12, 34…
## $ pct_relativehumidity_2m           <dbl> 52, 54, 55, 57, 57, 57, 57, 57, 57, …
## $ pct_dewpoint_2m                   <dbl> 15, 15, 15, 14, 14, 14, 14, 14, 15, …
## $ pct_apparent_temperature          <dbl> 4, 3, 3, 2, 2, 2, 2, 2, 2, 4, 10, 28…
## $ pct_pressure_msl                  <dbl> 100, 100, 99, 99, 99, 99, 98, 98, 98…
## $ pct_surface_pressure              <dbl> 99, 99, 99, 99, 98, 98, 97, 97, 97, …
## $ pct_precipitation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_rain                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_snowfall                      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover                    <dbl> 58, 63, 65, 71, 75, 73, 71, 73, 75, …
## $ pct_cloudcover_low                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover_mid                <dbl> 0, 0, 0, 0, 76, 0, 0, 0, 78, 80, 78,…
## $ pct_cloudcover_high               <dbl> 80, 84, 85, 91, 96, 95, 94, 95, 96, …
## $ pct_shortwave_radiation           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 59, 6…
## $ pct_direct_radiation              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 55, 6…
## $ pct_direct_normal_irradiance      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 54, 6…
## $ pct_diffuse_radiation             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 86, 9…
## $ pct_windspeed_10m                 <dbl> 61, 64, 65, 77, 77, 79, 79, 79, 79, …
## $ pct_windspeed_100m                <dbl> 60, 61, 63, 81, 80, 80, 79, 79, 78, …
## $ pct_winddirection_10m             <dbl> 6, 5, 3, 7, 7, 8, 7, 5, 5, 5, 7, 9, …
## $ pct_winddirection_100m            <dbl> 8, 10, 8, 8, 7, 8, 7, 7, 6, 4, 4, 4,…
## $ pct_windgusts_10m                 <dbl> 51, 51, 52, 53, 56, 58, 58, 59, 58, …
## $ pct_et0_fao_evapotranspiration    <dbl> 34, 34, 34, 34, 34, 34, 34, 34, 34, …
## $ pct_weathercode                   <dbl> 0, 63, 63, 63, 63, 63, 63, 63, 63, 6…
## $ pct_vapor_pressure_deficit        <dbl> 31, 29, 28, 27, 27, 27, 26, 27, 27, …
## $ pct_soil_temperature_0_to_7cm     <dbl> 3, 3, 2, 2, 2, 1, 1, 1, 1, 2, 5, 15,…
## $ pct_soil_temperature_7_to_28cm    <dbl> 6, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, …
## $ pct_soil_temperature_28_to_100cm  <dbl> 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, …
## $ pct_soil_temperature_100_to_255cm <dbl> 64, 64, 64, 64, 64, 64, 64, 64, 64, …
## $ pct_soil_moisture_0_to_7cm        <dbl> 83, 83, 83, 83, 83, 83, 83, 83, 83, …
## $ pct_soil_moisture_7_to_28cm       <dbl> 87, 87, 87, 87, 87, 87, 87, 87, 87, …
## $ pct_soil_moisture_28_to_100cm     <dbl> 56, 56, 56, 56, 56, 56, 56, 56, 56, …
## $ pct_soil_moisture_100_to_255cm    <dbl> 34, 34, 34, 34, 34, 34, 34, 34, 34, …
## $ pct_year                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_doy                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

## # A tibble: 8 × 4
##   todSeason    season tod       n
##   <fct>        <fct>  <fct> <int>
## 1 Spring-Day   Spring Day   15456
## 2 Spring-Night Spring Night 15456
## 3 Summer-Day   Summer Day   15456
## 4 Summer-Night Summer Night 15456
## 5 Fall-Day     Fall   Day   15288
## 6 Fall-Night   Fall   Night 15288
## 7 Winter-Day   Winter Day   15156
## 8 Winter-Night Winter Night 15156
## # A tibble: 24 × 4
##     hour fct_hour tod       n
##    <int> <fct>    <fct> <int>
##  1     0 0        Night  5113
##  2     1 1        Night  5113
##  3     2 2        Night  5113
##  4     3 3        Night  5113
##  5     4 4        Night  5113
##  6     5 5        Night  5113
##  7     6 6        Night  5113
##  8     7 7        Day    5113
##  9     8 8        Day    5113
## 10     9 9        Day    5113
## 11    10 10       Day    5113
## 12    11 11       Day    5113
## 13    12 12       Day    5113
## 14    13 13       Day    5113
## 15    14 14       Day    5113
## 16    15 15       Day    5113
## 17    16 16       Day    5113
## 18    17 17       Day    5113
## 19    18 18       Day    5113
## 20    19 19       Night  5113
## 21    20 20       Night  5113
## 22    21 21       Night  5113
## 23    22 22       Night  5113
## 24    23 23       Night  5113
## # A tibble: 12 × 3
##    month season     n
##    <fct> <fct>  <int>
##  1 Jan   Winter 10416
##  2 Feb   Winter  9480
##  3 Mar   Spring 10416
##  4 Apr   Spring 10080
##  5 May   Spring 10416
##  6 Jun   Summer 10080
##  7 Jul   Summer 10416
##  8 Aug   Summer 10416
##  9 Sep   Fall   10080
## 10 Oct   Fall   10416
## 11 Nov   Fall   10080
## 12 Dec   Winter 10416

Processed hourly data for Chicago and Houston are loaded:

# Read hourly JSON file (CHI and HOU)
chiTemp <- formatOpenMeteoJSON("testOM_hourly_chi.json", addVars=TRUE)
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, hourly_units, hourly 
## 
## $tblDaily
## NULL
## 
## $tblHourly
## # A tibble: 122,712 × 37
##    time                date        hour temperature_2m relativehumidity_2m
##    <dttm>              <date>     <int>          <dbl>               <int>
##  1 2010-01-01 00:00:00 2010-01-01     0           -9.5                  67
##  2 2010-01-01 01:00:00 2010-01-01     1           -9.8                  69
##  3 2010-01-01 02:00:00 2010-01-01     2          -10.3                  73
##  4 2010-01-01 03:00:00 2010-01-01     3          -10.8                  74
##  5 2010-01-01 04:00:00 2010-01-01     4          -11.3                  75
##  6 2010-01-01 05:00:00 2010-01-01     5          -11.8                  76
##  7 2010-01-01 06:00:00 2010-01-01     6          -12.3                  77
##  8 2010-01-01 07:00:00 2010-01-01     7          -12.8                  78
##  9 2010-01-01 08:00:00 2010-01-01     8          -13.2                  79
## 10 2010-01-01 09:00:00 2010-01-01     9          -13.4                  78
## # ℹ 122,702 more rows
## # ℹ 32 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
## 
## $tblUnits
## # A tibble: 34 × 4
##    metricType   name                 value   description                        
##    <chr>        <chr>                <chr>   <chr>                              
##  1 hourly_units time                 iso8601 <NA>                               
##  2 hourly_units temperature_2m       deg C   Air temperature at 2 meters above …
##  3 hourly_units relativehumidity_2m  %       Relative humidity at 2 meters abov…
##  4 hourly_units dewpoint_2m          deg C   Dew point temperature at 2 meters …
##  5 hourly_units apparent_temperature deg C   Apparent temperature is the percei…
##  6 hourly_units pressure_msl         hPa     Atmospheric air pressure reduced t…
##  7 hourly_units surface_pressure     hPa     Atmospheric air pressure reduced t…
##  8 hourly_units precipitation        mm      Total precipitation (rain, showers…
##  9 hourly_units rain                 mm      Only liquid precipitation of the p…
## 10 hourly_units snowfall             cm      Snowfall amount of the preceding h…
## # ℹ 24 more rows
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone       
##      <dbl>     <dbl>             <dbl>              <int> <chr>          
## 1     41.9     -87.6             4476.             -18000 America/Chicago
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 41.86292
## longitude: -87.64877
## generationtime_ms: 4476.2
## utc_offset_seconds: -18000
## timezone: America/Chicago
## timezone_abbreviation: CDT
## elevation: 180
## 
## Rows: 122,712
## Columns: 80
## $ time                              <dttm> 2010-01-01 00:00:00, 2010-01-01 01:…
## $ date                              <date> 2010-01-01, 2010-01-01, 2010-01-01,…
## $ hour                              <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ temperature_2m                    <dbl> -9.5, -9.8, -10.3, -10.8, -11.3, -11…
## $ relativehumidity_2m               <int> 67, 69, 73, 74, 75, 76, 77, 78, 79, …
## $ dewpoint_2m                       <dbl> -14.4, -14.4, -14.2, -14.5, -14.8, -…
## $ apparent_temperature              <dbl> -15.8, -16.3, -16.8, -17.2, -17.7, -…
## $ pressure_msl                      <dbl> 1024.4, 1024.7, 1025.3, 1025.8, 1026…
## $ surface_pressure                  <dbl> 1000.8, 1001.1, 1001.6, 1002.1, 1002…
## $ precipitation                     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ rain                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ snowfall                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover                        <int> 62, 47, 20, 15, 15, 19, 25, 22, 22, …
## $ cloudcover_low                    <int> 69, 52, 22, 17, 17, 21, 28, 25, 25, …
## $ cloudcover_mid                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, …
## $ cloudcover_high                   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ shortwave_radiation               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 119, …
## $ direct_radiation                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 69, 14…
## $ direct_normal_irradiance          <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0…
## $ diffuse_radiation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 50, 7…
## $ windspeed_10m                     <dbl> 18.7, 20.1, 19.9, 19.5, 19.0, 19.4, …
## $ windspeed_100m                    <dbl> 25.9, 28.4, 29.2, 29.8, 30.1, 30.0, …
## $ winddirection_10m                 <int> 298, 291, 290, 289, 289, 288, 287, 2…
## $ winddirection_100m                <int> 299, 294, 294, 295, 295, 294, 295, 2…
## $ windgusts_10m                     <dbl> 33.8, 32.4, 34.2, 33.1, 31.3, 31.7, …
## $ et0_fao_evapotranspiration        <dbl> 0.02, 0.01, 0.01, 0.01, 0.01, 0.01, …
## $ weathercode                       <int> 2, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, …
## $ vapor_pressure_deficit            <dbl> 0.10, 0.09, 0.08, 0.07, 0.06, 0.06, …
## $ soil_temperature_0_to_7cm         <dbl> -1.5, -1.6, -1.8, -1.9, -2.1, -2.3, …
## $ soil_temperature_7_to_28cm        <dbl> -0.4, -0.4, -0.4, -0.4, -0.4, -0.4, …
## $ soil_temperature_28_to_100cm      <dbl> 2.4, 2.4, 2.4, 2.4, 2.3, 2.3, 2.3, 2…
## $ soil_temperature_100_to_255cm     <dbl> 9.0, 9.0, 9.0, 9.0, 8.9, 8.9, 8.9, 8…
## $ soil_moisture_0_to_7cm            <dbl> 0.295, 0.295, 0.294, 0.294, 0.294, 0…
## $ soil_moisture_7_to_28cm           <dbl> 0.300, 0.300, 0.300, 0.300, 0.300, 0…
## $ soil_moisture_28_to_100cm         <dbl> 0.334, 0.334, 0.334, 0.334, 0.334, 0…
## $ soil_moisture_100_to_255cm        <dbl> 0.310, 0.310, 0.310, 0.310, 0.311, 0…
## $ origTime                          <chr> "2010-01-01T00:00", "2010-01-01T01:0…
## $ year                              <dbl> 2010, 2010, 2010, 2010, 2010, 2010, …
## $ month                             <fct> Jan, Jan, Jan, Jan, Jan, Jan, Jan, J…
## $ fct_hour                          <fct> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ tod                               <fct> Night, Night, Night, Night, Night, N…
## $ doy                               <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season                            <fct> Winter, Winter, Winter, Winter, Wint…
## $ todSeason                         <fct> Winter-Night, Winter-Night, Winter-N…
## $ pct_hour                          <dbl> 0, 4, 8, 13, 17, 21, 25, 29, 33, 38,…
## $ pct_temperature_2m                <dbl> 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, …
## $ pct_relativehumidity_2m           <dbl> 33, 37, 46, 48, 50, 52, 55, 57, 59, …
## $ pct_dewpoint_2m                   <dbl> 4, 4, 5, 4, 4, 4, 4, 4, 3, 3, 3, 4, …
## $ pct_apparent_temperature          <dbl> 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, …
## $ pct_pressure_msl                  <dbl> 84, 85, 86, 88, 89, 89, 90, 91, 91, …
## $ pct_surface_pressure              <dbl> 80, 81, 83, 85, 85, 86, 87, 89, 89, …
## $ pct_precipitation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_rain                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_snowfall                      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover                    <dbl> 62, 55, 33, 30, 30, 33, 37, 35, 35, …
## $ pct_cloudcover_low                <dbl> 77, 74, 66, 64, 64, 66, 68, 67, 67, …
## $ pct_cloudcover_mid                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0,…
## $ pct_cloudcover_high               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_shortwave_radiation           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 63, 7…
## $ pct_direct_radiation              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 69, 7…
## $ pct_direct_normal_irradiance      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 76, 8…
## $ pct_diffuse_radiation             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 59, 6…
## $ pct_windspeed_10m                 <dbl> 66, 72, 71, 70, 68, 69, 65, 63, 59, …
## $ pct_windspeed_100m                <dbl> 59, 67, 69, 71, 72, 72, 67, 63, 61, …
## $ pct_winddirection_10m             <dbl> 87, 85, 84, 84, 84, 84, 83, 83, 83, …
## $ pct_winddirection_100m            <dbl> 86, 85, 85, 85, 85, 85, 85, 85, 84, …
## $ pct_windgusts_10m                 <dbl> 69, 65, 70, 67, 62, 63, 63, 61, 59, …
## $ pct_et0_fao_evapotranspiration    <dbl> 27, 16, 16, 16, 16, 16, 16, 16, 16, …
## $ pct_weathercode                   <dbl> 55, 34, 0, 0, 0, 0, 34, 34, 34, 0, 3…
## $ pct_vapor_pressure_deficit        <dbl> 17, 15, 12, 10, 7, 7, 5, 5, 5, 5, 5,…
## $ pct_soil_temperature_0_to_7cm     <dbl> 9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 2, …
## $ pct_soil_temperature_7_to_28cm    <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, …
## $ pct_soil_temperature_28_to_100cm  <dbl> 18, 18, 18, 18, 18, 18, 18, 18, 18, …
## $ pct_soil_temperature_100_to_255cm <dbl> 40, 40, 40, 40, 40, 40, 40, 40, 40, …
## $ pct_soil_moisture_0_to_7cm        <dbl> 80, 80, 80, 80, 80, 80, 80, 80, 80, …
## $ pct_soil_moisture_7_to_28cm       <dbl> 84, 84, 84, 84, 84, 84, 84, 84, 84, …
## $ pct_soil_moisture_28_to_100cm     <dbl> 99, 99, 99, 99, 99, 99, 99, 98, 98, …
## $ pct_soil_moisture_100_to_255cm    <dbl> 85, 85, 85, 85, 86, 86, 86, 86, 86, …
## $ pct_year                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_doy                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

## # A tibble: 8 × 4
##   todSeason    season tod       n
##   <fct>        <fct>  <fct> <int>
## 1 Spring-Day   Spring Day   15456
## 2 Spring-Night Spring Night 15456
## 3 Summer-Day   Summer Day   15456
## 4 Summer-Night Summer Night 15456
## 5 Fall-Day     Fall   Day   15288
## 6 Fall-Night   Fall   Night 15288
## 7 Winter-Day   Winter Day   15156
## 8 Winter-Night Winter Night 15156
## # A tibble: 24 × 4
##     hour fct_hour tod       n
##    <int> <fct>    <fct> <int>
##  1     0 0        Night  5113
##  2     1 1        Night  5113
##  3     2 2        Night  5113
##  4     3 3        Night  5113
##  5     4 4        Night  5113
##  6     5 5        Night  5113
##  7     6 6        Night  5113
##  8     7 7        Day    5113
##  9     8 8        Day    5113
## 10     9 9        Day    5113
## 11    10 10       Day    5113
## 12    11 11       Day    5113
## 13    12 12       Day    5113
## 14    13 13       Day    5113
## 15    14 14       Day    5113
## 16    15 15       Day    5113
## 17    16 16       Day    5113
## 18    17 17       Day    5113
## 19    18 18       Day    5113
## 20    19 19       Night  5113
## 21    20 20       Night  5113
## 22    21 21       Night  5113
## 23    22 22       Night  5113
## 24    23 23       Night  5113
## # A tibble: 12 × 3
##    month season     n
##    <fct> <fct>  <int>
##  1 Jan   Winter 10416
##  2 Feb   Winter  9480
##  3 Mar   Spring 10416
##  4 Apr   Spring 10080
##  5 May   Spring 10416
##  6 Jun   Summer 10080
##  7 Jul   Summer 10416
##  8 Aug   Summer 10416
##  9 Sep   Fall   10080
## 10 Oct   Fall   10416
## 11 Nov   Fall   10080
## 12 Dec   Winter 10416
houTemp <- formatOpenMeteoJSON("testOM_hourly_hou.json", addVars=TRUE)
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, hourly_units, hourly 
## 
## $tblDaily
## NULL
## 
## $tblHourly
## # A tibble: 122,712 × 37
##    time                date        hour temperature_2m relativehumidity_2m
##    <dttm>              <date>     <int>          <dbl>               <int>
##  1 2010-01-01 00:00:00 2010-01-01     0           10.9                  93
##  2 2010-01-01 01:00:00 2010-01-01     1            9.9                  92
##  3 2010-01-01 02:00:00 2010-01-01     2            8.6                  88
##  4 2010-01-01 03:00:00 2010-01-01     3            7.7                  86
##  5 2010-01-01 04:00:00 2010-01-01     4            7.2                  85
##  6 2010-01-01 05:00:00 2010-01-01     5            6.8                  84
##  7 2010-01-01 06:00:00 2010-01-01     6            6.4                  82
##  8 2010-01-01 07:00:00 2010-01-01     7            5.9                  83
##  9 2010-01-01 08:00:00 2010-01-01     8            5.6                  83
## 10 2010-01-01 09:00:00 2010-01-01     9            5.5                  82
## # ℹ 122,702 more rows
## # ℹ 32 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
## 
## $tblUnits
## # A tibble: 34 × 4
##    metricType   name                 value   description                        
##    <chr>        <chr>                <chr>   <chr>                              
##  1 hourly_units time                 iso8601 <NA>                               
##  2 hourly_units temperature_2m       deg C   Air temperature at 2 meters above …
##  3 hourly_units relativehumidity_2m  %       Relative humidity at 2 meters abov…
##  4 hourly_units dewpoint_2m          deg C   Dew point temperature at 2 meters …
##  5 hourly_units apparent_temperature deg C   Apparent temperature is the percei…
##  6 hourly_units pressure_msl         hPa     Atmospheric air pressure reduced t…
##  7 hourly_units surface_pressure     hPa     Atmospheric air pressure reduced t…
##  8 hourly_units precipitation        mm      Total precipitation (rain, showers…
##  9 hourly_units rain                 mm      Only liquid precipitation of the p…
## 10 hourly_units snowfall             cm      Snowfall amount of the preceding h…
## # ℹ 24 more rows
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone  
##      <dbl>     <dbl>             <dbl>              <int> <chr>     
## 1     29.8     -95.4             3762.             -18000 US/Central
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 29.77153
## longitude: -95.43555
## generationtime_ms: 3762.283
## utc_offset_seconds: -18000
## timezone: US/Central
## timezone_abbreviation: CDT
## elevation: 17
## 
## Rows: 122,712
## Columns: 80
## $ time                              <dttm> 2010-01-01 00:00:00, 2010-01-01 01:…
## $ date                              <date> 2010-01-01, 2010-01-01, 2010-01-01,…
## $ hour                              <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ temperature_2m                    <dbl> 10.9, 9.9, 8.6, 7.7, 7.2, 6.8, 6.4, …
## $ relativehumidity_2m               <int> 93, 92, 88, 86, 85, 84, 82, 83, 83, …
## $ dewpoint_2m                       <dbl> 9.8, 8.6, 6.7, 5.6, 4.8, 4.2, 3.6, 3…
## $ apparent_temperature              <dbl> 7.4, 5.7, 4.1, 3.2, 2.9, 2.4, 2.2, 1…
## $ pressure_msl                      <dbl> 1025.2, 1025.9, 1026.8, 1027.1, 1027…
## $ surface_pressure                  <dbl> 1023.1, 1023.8, 1024.7, 1025.0, 1025…
## $ precipitation                     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ rain                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ snowfall                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover                        <int> 90, 90, 88, 88, 89, 89, 86, 80, 90, …
## $ cloudcover_low                    <int> 100, 100, 98, 98, 99, 99, 96, 89, 10…
## $ cloudcover_mid                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover_high                   <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ shortwave_radiation               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 89, 1…
## $ direct_radiation                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 28, 58…
## $ direct_normal_irradiance          <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0…
## $ diffuse_radiation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 61, 1…
## $ windspeed_10m                     <dbl> 24.0, 25.9, 25.3, 23.5, 20.9, 20.7, …
## $ windspeed_100m                    <dbl> 37.4, 39.1, 38.4, 35.4, 32.0, 31.2, …
## $ winddirection_10m                 <int> 330, 333, 336, 339, 341, 340, 347, 3…
## $ winddirection_100m                <int> 332, 334, 337, 341, 343, 341, 347, 3…
## $ windgusts_10m                     <dbl> 44.3, 46.1, 46.8, 44.3, 41.0, 37.8, …
## $ et0_fao_evapotranspiration        <dbl> 0.00, 0.01, 0.01, 0.01, 0.02, 0.02, …
## $ weathercode                       <int> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, …
## $ vapor_pressure_deficit            <dbl> 0.10, 0.10, 0.14, 0.14, 0.16, 0.16, …
## $ soil_temperature_0_to_7cm         <dbl> 11.9, 11.5, 11.0, 10.5, 10.1, 9.8, 9…
## $ soil_temperature_7_to_28cm        <dbl> 12.3, 12.3, 12.2, 12.2, 12.1, 12.0, …
## $ soil_temperature_28_to_100cm      <dbl> 14.2, 14.2, 14.2, 14.2, 14.2, 14.2, …
## $ soil_temperature_100_to_255cm     <dbl> 20.9, 20.9, 20.9, 20.9, 20.9, 20.9, …
## $ soil_moisture_0_to_7cm            <dbl> 0.462, 0.462, 0.462, 0.462, 0.462, 0…
## $ soil_moisture_7_to_28cm           <dbl> 0.474, 0.474, 0.474, 0.474, 0.473, 0…
## $ soil_moisture_28_to_100cm         <dbl> 0.498, 0.498, 0.498, 0.498, 0.498, 0…
## $ soil_moisture_100_to_255cm        <dbl> 0.453, 0.453, 0.453, 0.453, 0.453, 0…
## $ origTime                          <chr> "2010-01-01T00:00", "2010-01-01T01:0…
## $ year                              <dbl> 2010, 2010, 2010, 2010, 2010, 2010, …
## $ month                             <fct> Jan, Jan, Jan, Jan, Jan, Jan, Jan, J…
## $ fct_hour                          <fct> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ tod                               <fct> Night, Night, Night, Night, Night, N…
## $ doy                               <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season                            <fct> Winter, Winter, Winter, Winter, Wint…
## $ todSeason                         <fct> Winter-Night, Winter-Night, Winter-N…
## $ pct_hour                          <dbl> 0, 4, 8, 13, 17, 21, 25, 29, 33, 38,…
## $ pct_temperature_2m                <dbl> 12, 10, 8, 6, 6, 5, 5, 4, 4, 4, 4, 5…
## $ pct_relativehumidity_2m           <dbl> 80, 77, 67, 63, 61, 59, 55, 57, 57, …
## $ pct_dewpoint_2m                   <dbl> 23, 21, 17, 15, 13, 12, 11, 10, 9, 9…
## $ pct_apparent_temperature          <dbl> 11, 9, 6, 5, 5, 4, 4, 4, 4, 3, 3, 4,…
## $ pct_pressure_msl                  <dbl> 92, 93, 94, 95, 96, 97, 97, 97, 97, …
## $ pct_surface_pressure              <dbl> 92, 93, 94, 95, 96, 97, 97, 97, 98, …
## $ pct_precipitation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_rain                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_snowfall                      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover                    <dbl> 80, 80, 79, 79, 79, 79, 78, 76, 80, …
## $ pct_cloudcover_low                <dbl> 89, 89, 87, 87, 88, 88, 86, 84, 89, …
## $ pct_cloudcover_mid                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover_high               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_shortwave_radiation           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 59, 6…
## $ pct_direct_radiation              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 61, 6…
## $ pct_direct_normal_irradiance      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 63, 6…
## $ pct_diffuse_radiation             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 60, 7…
## $ pct_windspeed_10m                 <dbl> 95, 97, 96, 94, 90, 89, 83, 79, 78, …
## $ pct_windspeed_100m                <dbl> 96, 97, 97, 95, 90, 89, 82, 78, 76, …
## $ pct_winddirection_10m             <dbl> 91, 92, 92, 93, 93, 93, 95, 98, 96, …
## $ pct_winddirection_100m            <dbl> 92, 92, 93, 94, 94, 94, 96, 99, 97, …
## $ pct_windgusts_10m                 <dbl> 94, 96, 96, 94, 91, 87, 87, 84, 77, …
## $ pct_et0_fao_evapotranspiration    <dbl> 0, 24, 24, 24, 32, 32, 32, 24, 24, 3…
## $ pct_weathercode                   <dbl> 69, 69, 69, 69, 69, 69, 69, 69, 69, …
## $ pct_vapor_pressure_deficit        <dbl> 10, 10, 16, 16, 19, 19, 20, 19, 19, …
## $ pct_soil_temperature_0_to_7cm     <dbl> 10, 9, 8, 7, 6, 6, 5, 4, 4, 4, 4, 5,…
## $ pct_soil_temperature_7_to_28cm    <dbl> 6, 6, 6, 6, 6, 6, 5, 5, 5, 4, 4, 4, …
## $ pct_soil_temperature_28_to_100cm  <dbl> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, …
## $ pct_soil_temperature_100_to_255cm <dbl> 38, 38, 38, 38, 38, 38, 38, 38, 38, …
## $ pct_soil_moisture_0_to_7cm        <dbl> 82, 82, 82, 82, 82, 82, 82, 82, 82, …
## $ pct_soil_moisture_7_to_28cm       <dbl> 88, 88, 88, 88, 88, 88, 88, 88, 88, …
## $ pct_soil_moisture_28_to_100cm     <dbl> 98, 98, 98, 98, 98, 98, 98, 98, 98, …
## $ pct_soil_moisture_100_to_255cm    <dbl> 82, 82, 82, 82, 82, 82, 82, 82, 82, …
## $ pct_year                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_doy                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

## # A tibble: 8 × 4
##   todSeason    season tod       n
##   <fct>        <fct>  <fct> <int>
## 1 Spring-Day   Spring Day   15456
## 2 Spring-Night Spring Night 15456
## 3 Summer-Day   Summer Day   15456
## 4 Summer-Night Summer Night 15456
## 5 Fall-Day     Fall   Day   15288
## 6 Fall-Night   Fall   Night 15288
## 7 Winter-Day   Winter Day   15156
## 8 Winter-Night Winter Night 15156
## # A tibble: 24 × 4
##     hour fct_hour tod       n
##    <int> <fct>    <fct> <int>
##  1     0 0        Night  5113
##  2     1 1        Night  5113
##  3     2 2        Night  5113
##  4     3 3        Night  5113
##  5     4 4        Night  5113
##  6     5 5        Night  5113
##  7     6 6        Night  5113
##  8     7 7        Day    5113
##  9     8 8        Day    5113
## 10     9 9        Day    5113
## 11    10 10       Day    5113
## 12    11 11       Day    5113
## 13    12 12       Day    5113
## 14    13 13       Day    5113
## 15    14 14       Day    5113
## 16    15 15       Day    5113
## 17    16 16       Day    5113
## 18    17 17       Day    5113
## 19    18 18       Day    5113
## 20    19 19       Night  5113
## 21    20 20       Night  5113
## 22    21 21       Night  5113
## 23    22 22       Night  5113
## 24    23 23       Night  5113
## # A tibble: 12 × 3
##    month season     n
##    <fct> <fct>  <int>
##  1 Jan   Winter 10416
##  2 Feb   Winter  9480
##  3 Mar   Spring 10416
##  4 Apr   Spring 10080
##  5 May   Spring 10416
##  6 Jun   Summer 10080
##  7 Jul   Summer 10416
##  8 Aug   Summer 10416
##  9 Sep   Fall   10080
## 10 Oct   Fall   10416
## 11 Nov   Fall   10080
## 12 Dec   Winter 10416

An integrated set of all-city test and train data is created:

# Bind all the data frames
allCity <- list("NYC"=nycTemp, 
                "LA"=laxTemp, 
                "Chicago"=chiTemp, 
                "Houston"=houTemp
                ) %>%
    bind_rows(.id="src")

# Create the index for training data
set.seed(24061512)
idxTrain <- sample(1:nrow(allCity), size = round(0.7*nrow(allCity)), replace=FALSE)

# Add test-train flag to full dataset
allCity <- allCity %>%
    mutate(tt=ifelse(row_number() %in% idxTrain, "train", "test"), 
           fct_src=factor(src))
allCity
## # A tibble: 486,072 × 83
##    src   time                date        hour temperature_2m relativehumidity_2m
##    <chr> <dttm>              <date>     <int>          <dbl>               <int>
##  1 NYC   2010-01-01 00:00:00 2010-01-01     0           -1.1                  95
##  2 NYC   2010-01-01 01:00:00 2010-01-01     1           -1                    96
##  3 NYC   2010-01-01 02:00:00 2010-01-01     2           -1                    96
##  4 NYC   2010-01-01 03:00:00 2010-01-01     3           -0.8                  97
##  5 NYC   2010-01-01 04:00:00 2010-01-01     4           -0.9                  97
##  6 NYC   2010-01-01 05:00:00 2010-01-01     5           -0.8                  97
##  7 NYC   2010-01-01 06:00:00 2010-01-01     6           -0.7                  97
##  8 NYC   2010-01-01 07:00:00 2010-01-01     7           -0.5                  97
##  9 NYC   2010-01-01 08:00:00 2010-01-01     8           -0.6                  97
## 10 NYC   2010-01-01 09:00:00 2010-01-01     9           -0.6                  97
## # ℹ 486,062 more rows
## # ℹ 77 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
# Review counts by year
allCity %>% 
    count(year, src, tt) %>% 
    pivot_wider(id_cols=c("src", "tt"), names_from="year", values_from="n")
## # A tibble: 8 × 16
##   src     tt    `2010` `2011` `2012` `2013` `2014` `2015` `2016` `2017` `2018`
##   <chr>   <chr>  <int>  <int>  <int>  <int>  <int>  <int>  <int>  <int>  <int>
## 1 Chicago test    2555   2660   2671   2667   2612   2648   2550   2567   2648
## 2 Chicago train   6205   6100   6113   6093   6148   6112   6234   6193   6112
## 3 Houston test    2666   2562   2671   2621   2695   2639   2595   2688   2631
## 4 Houston train   6094   6198   6113   6139   6065   6121   6189   6072   6129
## 5 LA      test    2638   2653   2679   2591   2645   2634   2648   2579   2729
## 6 LA      train   6122   6107   6105   6169   6115   6126   6136   6181   6031
## 7 NYC     test    2644   2648   2579   2627   2645   2577   2603   2589   2618
## 8 NYC     train   6116   6112   6205   6133   6115   6183   6181   6171   6142
## # ℹ 5 more variables: `2019` <int>, `2020` <int>, `2021` <int>, `2022` <int>,
## #   `2023` <int>

Distributions of several key variables are explored:

keyVars <- c('temperature_2m', 
             'relativehumidity_2m', 
             'dewpoint_2m', 
             'shortwave_radiation', 
             'vapor_pressure_deficit', 
             'soil_temperature_28_to_100cm', 
             'soil_temperature_100_to_255cm', 
             'soil_moisture_28_to_100cm', 
             'soil_moisture_100_to_255cm'
             )

allCity %>%
    colSelector(vecSelect=c("src", keyVars)) %>%
    pivot_longer(cols=-c(src)) %>%
    ggplot(aes(x=src, y=value)) + 
    geom_boxplot(aes(fill=src)) + 
    facet_wrap(~name, scales="free_y") + 
    labs(x=NULL, y=NULL, title="Distribution of Key Metrics by City") + 
    scale_fill_discrete(NULL)

In addition, pair plots by city are create for several combinations of variables:

keyVars <- c('pressure_msl', 
             'surface_pressure', 
             'soil_temperature_100_to_255cm', 
             'soil_moisture_100_to_255cm'
             )

for(intCtr in 1:(length(keyVars)-1)) {
    for(intCtr2 in (intCtr+1):length(keyVars)) {
        p1 <- allCity %>%
            mutate(across(c("pressure_msl", "surface_pressure", "soil_temperature_100_to_255cm"), 
                          .fns=function(x) round(x*2)/2
                          ), 
                   soil_moisture_100_to_255cm=round(soil_moisture_100_to_255cm, 2)
                   ) %>%
            colSelector(vecSelect=c("src", keyVars[c(intCtr, intCtr2)])) %>%
            group_by(across(c("src", keyVars[c(intCtr, intCtr2)]))) %>%
            summarize(n=n(), .groups="drop") %>%
            ungroup() %>%
            ggplot(aes(x=get(keyVars[intCtr]), y=get(keyVars[intCtr2]))) + 
            geom_point(aes(color=src, size=n), alpha=0.25) + 
            labs(title="Distribution of Key Metrics by City", x=keyVars[intCtr], y=keyVars[intCtr2]) + 
            scale_size_continuous("# Obs")
        print(p1)
    }
}

The cities are well differentiated by several combinations, particularly surface pressure vs. MSL pressure

A full random forest model is run for predicting city using LA, NYC, and Chicago:

# Create set of relevant training variables
varsTrain <- allCity %>%
    select(starts_with("pct")) %>%
    names() %>%
    str_replace(pattern="pct_", replacement="")
varsTrain
##  [1] "hour"                          "temperature_2m"               
##  [3] "relativehumidity_2m"           "dewpoint_2m"                  
##  [5] "apparent_temperature"          "pressure_msl"                 
##  [7] "surface_pressure"              "precipitation"                
##  [9] "rain"                          "snowfall"                     
## [11] "cloudcover"                    "cloudcover_low"               
## [13] "cloudcover_mid"                "cloudcover_high"              
## [15] "shortwave_radiation"           "direct_radiation"             
## [17] "direct_normal_irradiance"      "diffuse_radiation"            
## [19] "windspeed_10m"                 "windspeed_100m"               
## [21] "winddirection_10m"             "winddirection_100m"           
## [23] "windgusts_10m"                 "et0_fao_evapotranspiration"   
## [25] "weathercode"                   "vapor_pressure_deficit"       
## [27] "soil_temperature_0_to_7cm"     "soil_temperature_7_to_28cm"   
## [29] "soil_temperature_28_to_100cm"  "soil_temperature_100_to_255cm"
## [31] "soil_moisture_0_to_7cm"        "soil_moisture_7_to_28cm"      
## [33] "soil_moisture_28_to_100cm"     "soil_moisture_100_to_255cm"   
## [35] "year"                          "doy"
keyLabel <- "predictions based on pre-2022 training data applied to 2022 holdout dataset"
keyCities <- c("NYC", "LA", "Chicago")

rfCity <- runFullRF(dfTrain=allCity %>% filter(tt=="train", year<2022, src %in% keyCities), 
                     yVar="fct_src", 
                     xVars=varsTrain, 
                     dfTest=allCity %>% filter(tt=="test", year==2022, src %in% keyCities), 
                     useLabel=keyLabel, 
                     useSub=stringr::str_to_sentence(keyLabel), 
                     returnData=TRUE
                     )
## Warning: Dropped unused factor level(s) in dependent variable: Houston.

## 
## Accuracy of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 100%

Prediction accuracy is 100%, as expected given the significant differentiation. Houston is assessed for the city it is “most similar” to:

predictRF(rfCity$rf, df=allCity %>% filter(tt=="test", year==2022)) %>%
    plotConfusion(trueCol="fct_src", useSub=NULL, plotCont=FALSE)

Based on predictors in the three-city random forest, Houston is most similar to NYC. The full random forest model is updated, including Houston:

keyCities <- c("NYC", "LA", "Chicago", "Houston")
rfCity <- runFullRF(dfTrain=allCity %>% filter(tt=="train", year<2022, src %in% keyCities), 
                    yVar="fct_src", 
                    xVars=varsTrain, 
                    dfTest=allCity %>% filter(tt=="test", year==2022, src %in% keyCities), 
                    useLabel=keyLabel, 
                    useSub=stringr::str_to_sentence(keyLabel), 
                    returnData=TRUE
                    )

## 
## Accuracy of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 100%

Even with the similarities between NYC and Houston, there is sufficient differentiation in the predictors to drive 100% accuracy

A model is created to predict temperature for two cities:

keyCities <- c("NYC", "Chicago")
keyLabel <- "predictions based on pre-2022 training data applied to 2022 holdout dataset"
rfTemp2m <- runFullRF(dfTrain=allCity %>% filter(tt=="train", year<2022, src %in% keyCities), 
                      yVar="temperature_2m", 
                      xVars=c(varsTrain[!str_detect(varsTrain, "^temp|ature$")]), 
                      dfTest=allCity %>% filter(tt=="test", year==2022, src %in% keyCities), 
                      useLabel=keyLabel, 
                      useSub=stringr::str_to_sentence(keyLabel), 
                      isContVar=TRUE,
                      rndTo=-1L,
                      refXY=TRUE,
                      returnData=TRUE
                      )
## Growing trees.. Progress: 65%. Estimated remaining time: 16 seconds.

## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.41% (RMSE 0.86 vs. 11.16 null)
## `geom_smooth()` using formula = 'y ~ x'

Temperature predictions on holdout data for NYC and Chicago have R-squared over 99%. The model is applied to data from Houston and LA:

# Temperature predictions for LA
predTempLA <- predictRF(rfTemp2m$rf, df=allCity %>% filter(tt=="test", year==2022, src=="LA"))
reportAccuracy(predTempLA, trueCol="temperature_2m", reportR2=TRUE, useLabel="LA temperature predictions")
## 
## R-squared of LA temperature predictions is: 92.38% (RMSE 1.89 vs. 6.86 null)
plotConfusion(predTempLA, trueCol="temperature_2m", plotCont=TRUE, rndTo=0.5, refXY=TRUE, useSub="LA")
## `geom_smooth()` using formula = 'y ~ x'

# Temperature predictions for Houston
predTempHOU <- predictRF(rfTemp2m$rf, df=allCity %>% filter(tt=="test", year==2022, src=="Houston"))
reportAccuracy(predTempHOU, trueCol="temperature_2m", reportR2=TRUE, useLabel="Houston temperature predictions")
## 
## R-squared of Houston temperature predictions is: 97.22% (RMSE 1.44 vs. 8.63 null)
plotConfusion(predTempHOU, trueCol="temperature_2m", plotCont=TRUE, rndTo=0.5, refXY=TRUE, useSub="Houston")
## `geom_smooth()` using formula = 'y ~ x'

Predictions for two cities not included in the original model have ~95% R-squared. Houston being relatively similar to NYC has higher R-squared than LA

Function runFullRF() is updated to allow for using an existing model with new data:

runFullRF <- function(dfTrain, 
                      yVar, 
                      xVars, 
                      useExistingRF=NULL,
                      dfTest=dfTrain,
                      useLabel="test data",
                      useSub=NULL, 
                      isContVar=FALSE,
                      rndTo=NULL,
                      rndBucketsAuto=100,
                      nSig=NULL,
                      refXY=FALSE,
                      makePlots=TRUE,
                      plotImp=makePlots,
                      plotConf=makePlots,
                      returnData=FALSE, 
                      ...
                      ) {
    
    # FUNCTION ARGUMENTS:
    # dfTrain: training data
    # yVar: dependent variable
    # xVars: column(s) containing independent variables
    # useExistingRF: an existing RF model, meaning only steps 3-5 are run (default NULL means run all steps)
    # dfTest: test dataset for applying predictions
    # useLabel: label to be used for reporting accuracy
    # useSub: subtitle to be used for confusion chart (NULL means none)
    # isContVar: boolean, is the variable continuous? (default FALSE means categorical)
    # rndTo: every number in x should be rounded to the nearest rndTo
    #        NULL means no rounding (default)
    #        -1L means make an estimate based on data
    # rndBucketsAuto: integer, if rndTo is -1L, about how many buckets are desired for predictions?
    # nSig: number of significant digits for automatically calculated rounding parameter
    #       (NULL means calculate exactly)    
    # refXY: boolean, should a reference line for y=x be included? (relevant only for continuous)
    # makePlots: boolean, should plots be created for variable importance and confusion matrix?
    # plotImp: boolean, should variable importance be plotted? (default is makePlots)
    # plotConf: boolean, should confusion matrix be plotted? (default is makePlots)
    # returnData: boolean, should data be returned?
    # ...: additional parameters to pass to runSimpleRF(), which are then passed to ranger::ranger()

    # Create the RF and plot importances, unless an RF is passed
    if(is.null(useExistingRF)) {
        # 1. Run random forest using impurity for importance
        rf <- runSimpleRF(df=dfTrain, yVar=yVar, xVars=xVars, importance="impurity", ...)

        # 2. Create, and optionally plot, variable importance
        rfImp <- plotRFImportance(rf, plotData=plotImp, returnData=TRUE)
    }
    else {
        rf <- useExistingRF
        rfImp <- NA
    }

    # 3. Predict on test dataset
    tstPred <- predictRF(rf=rf, df=dfTest)

    # 4. Report on accuracy (updated for continuous or categorical)
    rfAcc <- reportAccuracy(tstPred, 
                            trueCol=yVar, 
                            rndReport=3, 
                            useLabel=useLabel, 
                            reportR2=isTRUE(isContVar),
                            returnAcc=TRUE
                            )

    # 5. Plot confusion data (updated for continuous vs. categorical) if requested
    if(isTRUE(plotConf)) {
        plotConfusion(tstPred, 
                      trueCol=yVar, 
                      useSub=useSub, 
                      plotCont=isTRUE(isContVar), 
                      rndTo=rndTo, 
                      rndBucketsAuto=rndBucketsAuto,
                      nSig=nSig,
                      refXY=refXY
                      )
    }
    
    #6. Return data if requested
    if(isTRUE(returnData)) return(list(rf=rf, rfImp=rfImp, tstPred=tstPred, rfAcc=rfAcc))
    
}

Updated function runFullRF() is tested on LA and Houston:

# Temperature predictions for LA
runFullRF(yVar="temperature_2m", 
          useExistingRF=rfTemp2m$rf, 
          dfTest=allCity %>% filter(tt=="test", year==2022, src=="LA"), 
          useLabel="LA temperature predictions", 
          useSub="LA", 
          isContVar=TRUE,
          rndTo=0.5, 
          refXY=TRUE
          )
## 
## R-squared of LA temperature predictions is: 92.382% (RMSE 1.89 vs. 6.86 null)
## `geom_smooth()` using formula = 'y ~ x'

# Temperature predictions for Houston
runFullRF(yVar="temperature_2m", 
          useExistingRF=rfTemp2m$rf, 
          dfTest=allCity %>% filter(tt=="test", year==2022, src=="Houston"), 
          useLabel="Houston temperature predictions", 
          useSub="Houston", 
          isContVar=TRUE,
          rndTo=0.5, 
          refXY=TRUE
          )
## 
## R-squared of Houston temperature predictions is: 97.223% (RMSE 1.44 vs. 8.63 null)
## `geom_smooth()` using formula = 'y ~ x'

A basic linear model can potentially drive better temperature predictions:

keyCities <- c("NYC", "Chicago")
lmMiniTemp <- allCity %>% 
    filter(tt=="train", year<2022, src %in% keyCities) %>%
    select(t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m) %>%
    lm(t~rh+d+rh:d+1, data=.) 
summary(lmMiniTemp)
## 
## Call:
## lm(formula = t ~ rh + d + rh:d + 1, data = .)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8377 -0.4461 -0.1708  0.2944 12.0201 
## 
## Coefficients:
##               Estimate Std. Error  t value Pr(>|t|)    
## (Intercept)  2.158e+01  7.965e-03  2709.77   <2e-16 ***
## rh          -2.300e-01  1.150e-04 -1999.27   <2e-16 ***
## d            1.087e+00  6.448e-04  1685.07   <2e-16 ***
## rh:d        -5.407e-04  9.068e-06   -59.63   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6296 on 147464 degrees of freedom
## Multiple R-squared:  0.9966, Adjusted R-squared:  0.9966 
## F-statistic: 1.428e+07 on 3 and 147464 DF,  p-value: < 2.2e-16
ggMiniTemp <- predict(lmMiniTemp, 
                      newdata=allCity %>% 
                          filter(tt=="test", year==2022, src %in% keyCities) %>% 
                          select(rh=relativehumidity_2m, d=dewpoint_2m)
                      ) %>% 
    mutate(select(allCity %>% filter(tt=="test", year==2022, src %in% keyCities), temperature_2m), 
           pred=., 
           err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
           ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean))
ggMiniTemp
## # A tibble: 13 × 6
##     rnd5     n temperature_2m    pred     err     err2
##    <dbl> <dbl>          <dbl>   <dbl>   <dbl>    <dbl>
##  1   -25     2        -23.3   -23.3   -0.0227  0.00534
##  2   -20    15        -19.4   -19.1    0.270   0.187  
##  3   -15    60        -14.5   -14.3    0.238   0.189  
##  4   -10   201         -9.76   -9.54   0.221   0.263  
##  5    -5   377         -4.52   -4.35   0.177   0.245  
##  6     0   648          0.202   0.184 -0.0177  0.267  
##  7     5   730          4.95    4.97   0.0224  0.248  
##  8    10   719         10.2    10.1   -0.0591  0.302  
##  9    15   692         14.9    14.9   -0.0380  0.433  
## 10    20   920         20.1    20.2    0.0703  0.244  
## 11    25   654         24.7    24.6   -0.0569  1.12   
## 12    30   254         29.4    28.4   -0.984   3.56   
## 13    35    38         34.2    31.2   -2.99   12.9
ggMiniTemp %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using City Linear Model on Same City Holdout Data", 
         x="New city actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

Predictions can then be explored in cities not included in the original linear model, starting with Houston:

ggMiniTemp_hou <- predict(lmMiniTemp, 
                          newdata=allCity %>% 
                              filter(tt=="test", year==2022, src %in% c("Houston")) %>% 
                              select(rh=relativehumidity_2m, d=dewpoint_2m)
                          ) %>% 
    mutate(select(allCity %>% filter(tt=="test", year==2022, src %in% c("Houston")), temperature_2m), 
           pred=., 
           err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
           ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean))
ggMiniTemp_hou
## # A tibble: 11 × 6
##     rnd5     n temperature_2m   pred     err   err2
##    <dbl> <dbl>          <dbl>  <dbl>   <dbl>  <dbl>
##  1   -10     2         -7.95  -8.68  -0.730   0.600
##  2    -5    14         -4.25  -4.40  -0.150   0.428
##  3     0    38          0.429  0.608  0.179   0.222
##  4     5   197          5.21   5.29   0.0779  0.245
##  5    10   304          9.94   9.92  -0.0131  0.313
##  6    15   291         15.1   14.8   -0.292   0.700
##  7    20   507         20.3   20.0   -0.294   0.935
##  8    25   744         25.1   25.0   -0.0138  0.657
##  9    30   429         29.6   29.6    0.0214  1.12 
## 10    35   145         34.3   33.0   -1.30    2.92 
## 11    40     4         38.4   35.1   -3.34   11.3
ggMiniTemp_hou %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##     mse  rmse
##   <dbl> <dbl>
## 1 0.850 0.922
ggMiniTemp_hou %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using City Linear Model on New City (Houston) Holdout Data", 
         x="New city (Houston) actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

The linear model is generally very accurate for Houston, with the exception of under-predicting the very highest temperatures. RMSE of temperature predictions is lowered to ~1 from ~1.5 observed using the random forest

Predictions are also explored in Los Angeles:

ggMiniTemp_lax <- predict(lmMiniTemp, 
                          newdata=allCity %>% 
                              filter(tt=="test", year==2022, src %in% c("LA")) %>% 
                              select(rh=relativehumidity_2m, d=dewpoint_2m)
                          ) %>% 
    mutate(select(allCity %>% filter(tt=="test", year==2022, src %in% c("LA")), temperature_2m), 
           pred=., 
           err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
           ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean))
ggMiniTemp_lax
## # A tibble: 10 × 6
##     rnd5     n temperature_2m   pred     err    err2
##    <dbl> <dbl>          <dbl>  <dbl>   <dbl>   <dbl>
##  1     0     6           1.1   0.935  -0.165   0.205
##  2     5   127           5.72  5.52   -0.201   1.10 
##  3    10   605          10.2   9.20   -1.01    5.02 
##  4    15   754          15.1  13.9    -1.21    7.89 
##  5    20   585          19.7  17.5    -2.15   20.7  
##  6    25   331          24.7  22.1    -2.62   28.3  
##  7    30   176          29.7  24.2    -5.52   55.0  
##  8    35    49          34.4  25.9    -8.47   94.9  
##  9    40     7          38.9  28.6   -10.2   124.   
## 10    45     1          42.7  23.8   -18.9   356.
ggMiniTemp_lax %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##     mse  rmse
##   <dbl> <dbl>
## 1  17.5  4.18
ggMiniTemp_lax %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using City Linear Model on New City (LA) Holdout Data", 
         x="New city (LA) actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

The linear model is generally inaccurate for LA, consistently underestimating temperatures. RMSE of temperature predictions is raised to ~4 from ~2 observed using the random forest

Los Angeles is meaningfully different from NYC and Chicago on key predictors:

tmpPlotData <- allCity %>% 
    select(src, relativehumidity_2m, dewpoint_2m, temperature_2m) %>% 
    mutate(across(where(is.numeric), .fns=round)) %>% 
    count(src, relativehumidity_2m, dewpoint_2m, temperature_2m)

tmpPlotData %>%
    count(src, temperature_2m, dewpoint_2m, wt=n) %>%
    ggplot(aes(x=temperature_2m, y=dewpoint_2m)) + 
    geom_point(aes(color=src, size=n), alpha=0.2) + 
    geom_smooth(aes(color=src, weight=n), method="lm") +
    labs(title="T/D by city")
## `geom_smooth()` using formula = 'y ~ x'

tmpPlotData %>%
    count(src, temperature_2m, relativehumidity_2m, wt=n) %>%
    ggplot(aes(x=temperature_2m, y=relativehumidity_2m)) + 
    geom_point(aes(color=src, size=n), alpha=0.1) + 
    geom_smooth(aes(color=src, weight=n), method="lm") +
    labs(title="T/RH by city")
## `geom_smooth()` using formula = 'y ~ x'

Los Angeles is routinely hot and arid, while the other cities tend to be humid when they are hot. Data for an additional low-humidity city are downloaded, cached to avoid multiple hits to the server:

# Hourly data download for Las Vegas, NV
testURLHourly <- helperOpenMeteoURL(cityName="Las Vegas NV", 
                                    hourlyIndices=1:nrow(tblMetricsHourly),
                                    startDate="2010-01-01", 
                                    endDate="2023-12-31", 
                                    tz="America/Los_Angeles"
                                    )
## 
## Hourly metrics created from indices: temperature_2m,relativehumidity_2m,dewpoint_2m,apparent_temperature,pressure_msl,surface_pressure,precipitation,rain,snowfall,cloudcover,cloudcover_low,cloudcover_mid,cloudcover_high,shortwave_radiation,direct_radiation,direct_normal_irradiance,diffuse_radiation,windspeed_10m,windspeed_100m,winddirection_10m,winddirection_100m,windgusts_10m,et0_fao_evapotranspiration,weathercode,vapor_pressure_deficit,soil_temperature_0_to_7cm,soil_temperature_7_to_28cm,soil_temperature_28_to_100cm,soil_temperature_100_to_255cm,soil_moisture_0_to_7cm,soil_moisture_7_to_28cm,soil_moisture_28_to_100cm,soil_moisture_100_to_255cm
testURLHourly
## [1] "https://archive-api.open-meteo.com/v1/archive?latitude=36.21&longitude=-115.22&start_date=2010-01-01&end_date=2023-12-31&hourly=temperature_2m,relativehumidity_2m,dewpoint_2m,apparent_temperature,pressure_msl,surface_pressure,precipitation,rain,snowfall,cloudcover,cloudcover_low,cloudcover_mid,cloudcover_high,shortwave_radiation,direct_radiation,direct_normal_irradiance,diffuse_radiation,windspeed_10m,windspeed_100m,winddirection_10m,winddirection_100m,windgusts_10m,et0_fao_evapotranspiration,weathercode,vapor_pressure_deficit,soil_temperature_0_to_7cm,soil_temperature_7_to_28cm,soil_temperature_28_to_100cm,soil_temperature_100_to_255cm,soil_moisture_0_to_7cm,soil_moisture_7_to_28cm,soil_moisture_28_to_100cm,soil_moisture_100_to_255cm&timezone=America%2FLos_Angeles"
# Download file
if(!file.exists("testOM_hourly_las.json")) {
    fileDownload(fileName="testOM_hourly_las.json", url=testURLHourly)
} else {
    cat("\nFile testOM_hourly_las.json already exists, skipping download\n")
}
## 
## File testOM_hourly_las.json already exists, skipping download
# Daily data download for Las Vegas, NV
testURLDaily <- helperOpenMeteoURL(cityName="Las Vegas NV", 
                                   dailyIndices=1:nrow(tblMetricsDaily),
                                   startDate="2010-01-01", 
                                   endDate="2023-12-31", 
                                   tz="America/Los_Angeles"
                                   )
## 
## Daily metrics created from indices: weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,precipitation_sum,rain_sum,snowfall_sum,precipitation_hours,sunrise,sunset,windspeed_10m_max,windgusts_10m_max,winddirection_10m_dominant,shortwave_radiation_sum,et0_fao_evapotranspiration
testURLDaily
## [1] "https://archive-api.open-meteo.com/v1/archive?latitude=36.21&longitude=-115.22&start_date=2010-01-01&end_date=2023-12-31&daily=weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,precipitation_sum,rain_sum,snowfall_sum,precipitation_hours,sunrise,sunset,windspeed_10m_max,windgusts_10m_max,winddirection_10m_dominant,shortwave_radiation_sum,et0_fao_evapotranspiration&timezone=America%2FLos_Angeles"
# Download file
if(!file.exists("testOM_daily_las.json")) {
    fileDownload(fileName="testOM_daily_las.json", url=testURLDaily)
} else {
    cat("\nFile testOM_daily_las.json already exists, skipping download\n")
}
## 
## File testOM_daily_las.json already exists, skipping download

The daily and hourly datasets are loaded:

# Read daily JSON file
lasOMDaily <- formatOpenMeteoJSON("testOM_daily_las.json")
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, daily_units, daily 
## 
## $tblDaily
## # A tibble: 5,113 × 18
##    date       time       weathercode temperature_2m_max temperature_2m_min
##    <date>     <chr>            <int>              <dbl>              <dbl>
##  1 2010-01-01 2010-01-01           2               10.3               -1.3
##  2 2010-01-02 2010-01-02           0               14.2               -0.4
##  3 2010-01-03 2010-01-03           0               14.2                0.7
##  4 2010-01-04 2010-01-04           1               13.3                2.8
##  5 2010-01-05 2010-01-05           1               13.6                0.7
##  6 2010-01-06 2010-01-06           1               15.8                2.5
##  7 2010-01-07 2010-01-07           2               16.1                6  
##  8 2010-01-08 2010-01-08           1               11.2                1.2
##  9 2010-01-09 2010-01-09           1               13.2                0.5
## 10 2010-01-10 2010-01-10           2               15.6                5.9
## # ℹ 5,103 more rows
## # ℹ 13 more variables: apparent_temperature_max <dbl>,
## #   apparent_temperature_min <dbl>, precipitation_sum <dbl>, rain_sum <dbl>,
## #   snowfall_sum <dbl>, precipitation_hours <dbl>, sunrise <chr>, sunset <chr>,
## #   windspeed_10m_max <dbl>, windgusts_10m_max <dbl>,
## #   winddirection_10m_dominant <int>, shortwave_radiation_sum <dbl>,
## #   et0_fao_evapotranspiration <dbl>
## 
## $tblHourly
## NULL
## 
## $tblUnits
## # A tibble: 17 × 4
##    metricType  name                       value      description                
##    <chr>       <chr>                      <chr>      <chr>                      
##  1 daily_units time                       "iso8601"  <NA>                       
##  2 daily_units weathercode                "wmo code" The most severe weather co…
##  3 daily_units temperature_2m_max         "deg C"    Maximum and minimum daily …
##  4 daily_units temperature_2m_min         "deg C"    Maximum and minimum daily …
##  5 daily_units apparent_temperature_max   "deg C"    Maximum and minimum daily …
##  6 daily_units apparent_temperature_min   "deg C"    Maximum and minimum daily …
##  7 daily_units precipitation_sum          "mm"       Sum of daily precipitation…
##  8 daily_units rain_sum                   "mm"       Sum of daily rain          
##  9 daily_units snowfall_sum               "cm"       Sum of daily snowfall      
## 10 daily_units precipitation_hours        "h"        The number of hours with r…
## 11 daily_units sunrise                    "iso8601"  Sun rise and set times     
## 12 daily_units sunset                     "iso8601"  Sun rise and set times     
## 13 daily_units windspeed_10m_max          "km/h"     Maximum wind speed and gus…
## 14 daily_units windgusts_10m_max          "km/h"     Maximum wind speed and gus…
## 15 daily_units winddirection_10m_dominant "deg "     Dominant wind direction    
## 16 daily_units shortwave_radiation_sum    "MJ/m²"    The sum of solar radiaion …
## 17 daily_units et0_fao_evapotranspiration "mm"       Daily sum of ET0 Reference…
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone           
##      <dbl>     <dbl>             <dbl>              <int> <chr>              
## 1     36.2     -115.              69.8             -25200 America/Los_Angeles
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 36.23901
## longitude: -115.1625
## generationtime_ms: 69.77499
## utc_offset_seconds: -25200
## timezone: America/Los_Angeles
## timezone_abbreviation: PDT
## elevation: 686
# Read hourly JSON file
lasTemp <- formatOpenMeteoJSON("testOM_hourly_las.json", addVars=TRUE)
## 
## Objects in JSON include: latitude, longitude, generationtime_ms, utc_offset_seconds, timezone, timezone_abbreviation, elevation, hourly_units, hourly 
## 
## $tblDaily
## NULL
## 
## $tblHourly
## # A tibble: 122,712 × 37
##    time                date        hour temperature_2m relativehumidity_2m
##    <dttm>              <date>     <int>          <dbl>               <int>
##  1 2010-01-01 00:00:00 2010-01-01     0            1.3                  53
##  2 2010-01-01 01:00:00 2010-01-01     1            0.5                  56
##  3 2010-01-01 02:00:00 2010-01-01     2            0.1                  56
##  4 2010-01-01 03:00:00 2010-01-01     3           -0.3                  57
##  5 2010-01-01 04:00:00 2010-01-01     4           -0.8                  59
##  6 2010-01-01 05:00:00 2010-01-01     5           -1.1                  60
##  7 2010-01-01 06:00:00 2010-01-01     6           -1.3                  60
##  8 2010-01-01 07:00:00 2010-01-01     7           -1.2                  58
##  9 2010-01-01 08:00:00 2010-01-01     8           -1.2                  56
## 10 2010-01-01 09:00:00 2010-01-01     9           -0.1                  56
## # ℹ 122,702 more rows
## # ℹ 32 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
## 
## $tblUnits
## # A tibble: 34 × 4
##    metricType   name                 value   description                        
##    <chr>        <chr>                <chr>   <chr>                              
##  1 hourly_units time                 iso8601 <NA>                               
##  2 hourly_units temperature_2m       deg C   Air temperature at 2 meters above …
##  3 hourly_units relativehumidity_2m  %       Relative humidity at 2 meters abov…
##  4 hourly_units dewpoint_2m          deg C   Dew point temperature at 2 meters …
##  5 hourly_units apparent_temperature deg C   Apparent temperature is the percei…
##  6 hourly_units pressure_msl         hPa     Atmospheric air pressure reduced t…
##  7 hourly_units surface_pressure     hPa     Atmospheric air pressure reduced t…
##  8 hourly_units precipitation        mm      Total precipitation (rain, showers…
##  9 hourly_units rain                 mm      Only liquid precipitation of the p…
## 10 hourly_units snowfall             cm      Snowfall amount of the preceding h…
## # ℹ 24 more rows
## 
## $tblDescription
## # A tibble: 1 × 7
##   latitude longitude generationtime_ms utc_offset_seconds timezone           
##      <dbl>     <dbl>             <dbl>              <int> <chr>              
## 1     36.2     -115.             7256.             -25200 America/Los_Angeles
## # ℹ 2 more variables: timezone_abbreviation <chr>, elevation <dbl>
## 
## 
## latitude: 36.23901
## longitude: -115.1625
## generationtime_ms: 7256.367
## utc_offset_seconds: -25200
## timezone: America/Los_Angeles
## timezone_abbreviation: PDT
## elevation: 686
## 
## Rows: 122,712
## Columns: 80
## $ time                              <dttm> 2010-01-01 00:00:00, 2010-01-01 01:…
## $ date                              <date> 2010-01-01, 2010-01-01, 2010-01-01,…
## $ hour                              <int> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ temperature_2m                    <dbl> 1.3, 0.5, 0.1, -0.3, -0.8, -1.1, -1.…
## $ relativehumidity_2m               <int> 53, 56, 56, 57, 59, 60, 60, 58, 56, …
## $ dewpoint_2m                       <dbl> -7.2, -7.3, -7.6, -7.7, -7.8, -7.9, …
## $ apparent_temperature              <dbl> -2.5, -3.3, -3.6, -4.1, -4.3, -4.7, …
## $ pressure_msl                      <dbl> 1031.2, 1031.1, 1030.8, 1031.7, 1031…
## $ surface_pressure                  <dbl> 947.4, 947.1, 946.7, 947.4, 946.9, 9…
## $ precipitation                     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ rain                              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ snowfall                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover                        <int> 12, 12, 12, 12, 12, 9, 11, 6, 3, 19,…
## $ cloudcover_low                    <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ cloudcover_mid                    <int> 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 28,…
## $ cloudcover_high                   <int> 40, 40, 40, 39, 40, 29, 32, 19, 10, …
## $ shortwave_radiation               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 240, …
## $ direct_radiation                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 185, …
## $ direct_normal_irradiance          <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0…
## $ diffuse_radiation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 55, 6…
## $ windspeed_10m                     <dbl> 5.0, 5.5, 4.7, 4.9, 3.1, 3.5, 3.4, 3…
## $ windspeed_100m                    <dbl> 5.7, 7.2, 6.9, 6.5, 6.3, 6.0, 6.9, 6…
## $ winddirection_10m                 <int> 291, 293, 293, 287, 291, 294, 302, 2…
## $ winddirection_100m                <int> 342, 342, 351, 354, 24, 17, 6, 6, 35…
## $ windgusts_10m                     <dbl> 9.7, 10.1, 10.1, 9.7, 9.0, 9.0, 9.0,…
## $ et0_fao_evapotranspiration        <dbl> 0.01, 0.01, 0.01, 0.01, 0.00, 0.00, …
## $ weathercode                       <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, …
## $ vapor_pressure_deficit            <dbl> 0.31, 0.28, 0.27, 0.26, 0.24, 0.23, …
## $ soil_temperature_0_to_7cm         <dbl> 0.0, -0.3, -0.6, -0.8, -1.0, -1.1, -…
## $ soil_temperature_7_to_28cm        <dbl> 5.2, 5.1, 5.0, 4.9, 4.7, 4.6, 4.5, 4…
## $ soil_temperature_28_to_100cm      <dbl> 10.2, 10.2, 10.2, 10.2, 10.2, 10.2, …
## $ soil_temperature_100_to_255cm     <dbl> 21.3, 21.3, 21.3, 21.3, 21.3, 21.3, …
## $ soil_moisture_0_to_7cm            <dbl> 0.069, 0.069, 0.069, 0.069, 0.069, 0…
## $ soil_moisture_7_to_28cm           <dbl> 0.126, 0.126, 0.126, 0.126, 0.126, 0…
## $ soil_moisture_28_to_100cm         <dbl> 0.142, 0.142, 0.142, 0.142, 0.142, 0…
## $ soil_moisture_100_to_255cm        <dbl> 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, …
## $ origTime                          <chr> "2010-01-01T00:00", "2010-01-01T01:0…
## $ year                              <dbl> 2010, 2010, 2010, 2010, 2010, 2010, …
## $ month                             <fct> Jan, Jan, Jan, Jan, Jan, Jan, Jan, J…
## $ fct_hour                          <fct> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11…
## $ tod                               <fct> Night, Night, Night, Night, Night, N…
## $ doy                               <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ season                            <fct> Winter, Winter, Winter, Winter, Wint…
## $ todSeason                         <fct> Winter-Night, Winter-Night, Winter-N…
## $ pct_hour                          <dbl> 0, 4, 8, 13, 17, 21, 25, 29, 33, 38,…
## $ pct_temperature_2m                <dbl> 2, 1, 1, 1, 1, 1, 0, 0, 0, 1, 4, 10,…
## $ pct_relativehumidity_2m           <dbl> 87, 88, 88, 89, 90, 91, 91, 90, 88, …
## $ pct_dewpoint_2m                   <dbl> 23, 22, 21, 21, 20, 20, 19, 18, 17, …
## $ pct_apparent_temperature          <dbl> 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 10,…
## $ pct_pressure_msl                  <dbl> 99, 99, 99, 99, 99, 99, 99, 99, 99, …
## $ pct_surface_pressure              <dbl> 98, 98, 98, 98, 98, 98, 98, 98, 98, …
## $ pct_precipitation                 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_rain                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_snowfall                      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover                    <dbl> 65, 65, 65, 65, 65, 62, 64, 59, 54, …
## $ pct_cloudcover_low                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_cloudcover_mid                <dbl> 0, 0, 0, 0, 0, 0, 73, 0, 0, 0, 70, 8…
## $ pct_cloudcover_high               <dbl> 75, 75, 75, 74, 75, 71, 72, 68, 64, …
## $ pct_shortwave_radiation           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 64, 7…
## $ pct_direct_radiation              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 66, 7…
## $ pct_direct_normal_irradiance      <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 74, 8…
## $ pct_diffuse_radiation             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 59, 6…
## $ pct_windspeed_10m                 <dbl> 27, 33, 24, 27, 10, 14, 13, 11, 19, …
## $ pct_windspeed_100m                <dbl> 24, 33, 31, 29, 28, 26, 31, 31, 27, …
## $ pct_winddirection_10m             <dbl> 75, 76, 76, 74, 75, 76, 79, 77, 74, …
## $ pct_winddirection_100m            <dbl> 94, 94, 96, 97, 7, 5, 1, 1, 96, 93, …
## $ pct_windgusts_10m                 <dbl> 15, 17, 17, 15, 12, 12, 12, 12, 9, 1…
## $ pct_et0_fao_evapotranspiration    <dbl> 5, 5, 5, 5, 0, 0, 0, 0, 0, 10, 37, 5…
## $ pct_weathercode                   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,…
## $ pct_vapor_pressure_deficit        <dbl> 5, 4, 4, 4, 3, 3, 3, 3, 3, 4, 7, 19,…
## $ pct_soil_temperature_0_to_7cm     <dbl> 2, 2, 1, 1, 1, 1, 1, 1, 0, 1, 2, 4, …
## $ pct_soil_temperature_7_to_28cm    <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, …
## $ pct_soil_temperature_28_to_100cm  <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, …
## $ pct_soil_temperature_100_to_255cm <dbl> 44, 44, 44, 44, 44, 44, 44, 44, 44, …
## $ pct_soil_moisture_0_to_7cm        <dbl> 88, 88, 88, 88, 88, 88, 88, 88, 88, …
## $ pct_soil_moisture_7_to_28cm       <dbl> 75, 75, 75, 75, 75, 75, 75, 75, 75, …
## $ pct_soil_moisture_28_to_100cm     <dbl> 64, 64, 64, 64, 64, 64, 64, 64, 64, …
## $ pct_soil_moisture_100_to_255cm    <dbl> 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, …
## $ pct_year                          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
## $ pct_doy                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …

## # A tibble: 8 × 4
##   todSeason    season tod       n
##   <fct>        <fct>  <fct> <int>
## 1 Spring-Day   Spring Day   15456
## 2 Spring-Night Spring Night 15456
## 3 Summer-Day   Summer Day   15456
## 4 Summer-Night Summer Night 15456
## 5 Fall-Day     Fall   Day   15288
## 6 Fall-Night   Fall   Night 15288
## 7 Winter-Day   Winter Day   15156
## 8 Winter-Night Winter Night 15156
## # A tibble: 24 × 4
##     hour fct_hour tod       n
##    <int> <fct>    <fct> <int>
##  1     0 0        Night  5113
##  2     1 1        Night  5113
##  3     2 2        Night  5113
##  4     3 3        Night  5113
##  5     4 4        Night  5113
##  6     5 5        Night  5113
##  7     6 6        Night  5113
##  8     7 7        Day    5113
##  9     8 8        Day    5113
## 10     9 9        Day    5113
## 11    10 10       Day    5113
## 12    11 11       Day    5113
## 13    12 12       Day    5113
## 14    13 13       Day    5113
## 15    14 14       Day    5113
## 16    15 15       Day    5113
## 17    16 16       Day    5113
## 18    17 17       Day    5113
## 19    18 18       Day    5113
## 20    19 19       Night  5113
## 21    20 20       Night  5113
## 22    21 21       Night  5113
## 23    22 22       Night  5113
## 24    23 23       Night  5113
## # A tibble: 12 × 3
##    month season     n
##    <fct> <fct>  <int>
##  1 Jan   Winter 10416
##  2 Feb   Winter  9480
##  3 Mar   Spring 10416
##  4 Apr   Spring 10080
##  5 May   Spring 10416
##  6 Jun   Summer 10080
##  7 Jul   Summer 10416
##  8 Aug   Summer 10416
##  9 Sep   Fall   10080
## 10 Oct   Fall   10416
## 11 Nov   Fall   10080
## 12 Dec   Winter 10416

An integrated set of all-city test and train data is updated:

# Bind all the data frames
allCity <- list("NYC"=nycTemp, 
                "LA"=laxTemp, 
                "Chicago"=chiTemp, 
                "Houston"=houTemp, 
                "Vegas"=lasTemp
                ) %>%
    bind_rows(.id="src")

# Create the index for training data
set.seed(24070113)
idxTrain_v2 <- sample(1:nrow(allCity), size = round(0.7*nrow(allCity)), replace=FALSE)

# Add test-train flag to full dataset
allCity <- allCity %>%
    mutate(tt=ifelse(row_number() %in% idxTrain_v2, "train", "test"), 
           fct_src=factor(src))
allCity
## # A tibble: 608,784 × 83
##    src   time                date        hour temperature_2m relativehumidity_2m
##    <chr> <dttm>              <date>     <int>          <dbl>               <int>
##  1 NYC   2010-01-01 00:00:00 2010-01-01     0           -1.1                  95
##  2 NYC   2010-01-01 01:00:00 2010-01-01     1           -1                    96
##  3 NYC   2010-01-01 02:00:00 2010-01-01     2           -1                    96
##  4 NYC   2010-01-01 03:00:00 2010-01-01     3           -0.8                  97
##  5 NYC   2010-01-01 04:00:00 2010-01-01     4           -0.9                  97
##  6 NYC   2010-01-01 05:00:00 2010-01-01     5           -0.8                  97
##  7 NYC   2010-01-01 06:00:00 2010-01-01     6           -0.7                  97
##  8 NYC   2010-01-01 07:00:00 2010-01-01     7           -0.5                  97
##  9 NYC   2010-01-01 08:00:00 2010-01-01     8           -0.6                  97
## 10 NYC   2010-01-01 09:00:00 2010-01-01     9           -0.6                  97
## # ℹ 608,774 more rows
## # ℹ 77 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …
# Review counts by year
allCity %>% 
    count(year, src, tt) %>% 
    pivot_wider(id_cols=c("src", "tt"), names_from="year", values_from="n")
## # A tibble: 10 × 16
##    src     tt    `2010` `2011` `2012` `2013` `2014` `2015` `2016` `2017` `2018`
##    <chr>   <chr>  <int>  <int>  <int>  <int>  <int>  <int>  <int>  <int>  <int>
##  1 Chicago test    2569   2593   2572   2660   2623   2591   2583   2679   2692
##  2 Chicago train   6191   6167   6212   6100   6137   6169   6201   6081   6068
##  3 Houston test    2687   2539   2612   2665   2675   2607   2652   2686   2662
##  4 Houston train   6073   6221   6172   6095   6085   6153   6132   6074   6098
##  5 LA      test    2565   2607   2588   2674   2627   2641   2685   2650   2655
##  6 LA      train   6195   6153   6196   6086   6133   6119   6099   6110   6105
##  7 NYC     test    2633   2602   2622   2623   2672   2583   2603   2607   2670
##  8 NYC     train   6127   6158   6162   6137   6088   6177   6181   6153   6090
##  9 Vegas   test    2582   2528   2642   2619   2633   2587   2650   2679   2618
## 10 Vegas   train   6178   6232   6142   6141   6127   6173   6134   6081   6142
## # ℹ 5 more variables: `2019` <int>, `2020` <int>, `2021` <int>, `2022` <int>,
## #   `2023` <int>

Distributions of several key variables are explored:

keyVars <- c('temperature_2m', 
             'relativehumidity_2m', 
             'dewpoint_2m', 
             'shortwave_radiation', 
             'vapor_pressure_deficit', 
             'soil_temperature_28_to_100cm', 
             'soil_temperature_100_to_255cm', 
             'soil_moisture_28_to_100cm', 
             'soil_moisture_100_to_255cm'
             )

allCity %>%
    colSelector(vecSelect=c("src", keyVars)) %>%
    pivot_longer(cols=-c(src)) %>%
    ggplot(aes(x=src, y=value)) + 
    geom_boxplot(aes(fill=src)) + 
    facet_wrap(~name, scales="free_y") + 
    labs(x=NULL, y=NULL, title="Distribution of Key Metrics by City") + 
    scale_fill_discrete(NULL)

Las Vegas stands out for especially low relative humidity (even relative to LA), as well as dry soil (similar to LA)

The scatter of temperature and dewpoint is also explored:

allCity %>% 
    select(t=temperature_2m, d=dewpoint_2m, src) %>% 
    mutate(across(.cols=where(is.numeric), .fns=function(x) round(x))) %>% 
    count(src, t, d) %>% 
    ggplot(aes(x=t, y=d)) + 
    geom_point(aes(size=n, color=src), alpha=0.5) + 
    geom_smooth(aes(color=src, weight=n), method="lm") +
    labs(x="Temperature (C)", y="Dewpoint (C)", title="Temperature vs. Dewpoint", subtitle="Hourly") + 
    scale_color_discrete(NULL) + 
    scale_size_continuous("# Obs")
## `geom_smooth()` using formula = 'y ~ x'

allCity %>% 
    group_by(src) %>%
    summarize(cor_td=cor(temperature_2m, dewpoint_2m))
## # A tibble: 5 × 2
##   src     cor_td
##   <chr>    <dbl>
## 1 Chicago  0.950
## 2 Houston  0.834
## 3 LA       0.273
## 4 NYC      0.919
## 5 Vegas    0.371

Las Vegas is similar to LA, with lower dewpoints. The more humid cities have 80%+ correlation between temperature and dewpoint, dropping to ~40% correlation in the drier cities

Models for predicting city (one with soil temperature, one without) are saved using data without Las Vegas, for application to the new Las Vegas data:

# Run with all variables
rfCityFull <- runFullRF(allCity %>% 
                            mutate(fct_src=factor(src)) %>% 
                            filter(year<2022, tt=="train", src!="Vegas"), 
                        yVar="fct_src", 
                        xVars=varsTrain, 
                        dfTest=allCity %>% 
                            mutate(fct_src=factor(src)) %>% 
                            filter(year==2022, tt=="test", src!="Vegas"), 
                        isContVar=FALSE, 
                        returnData=TRUE
                        )
## Warning: Dropped unused factor level(s) in dependent variable: Vegas.
## Growing trees.. Progress: 97%. Estimated remaining time: 0 seconds.

## 
## Accuracy of test data is: 100%

predictRF(rfCityFull$rf, df=allCity %>% filter(src=="Vegas")) %>% count(pred)
## # A tibble: 1 × 2
##   pred       n
##   <fct>  <int>
## 1 LA    122712
# Run without moisture variables
rfCityNoMoisture <- runFullRF(allCity %>% 
                                  mutate(fct_src=factor(src)) %>% 
                                  filter(year<2022, tt=="train", src!="Vegas"), 
                              yVar="fct_src", 
                              xVars=varsTrain[!grepl(pattern="moist", x=varsTrain)],
                              dfTest=allCity %>% 
                                  mutate(fct_src=factor(src)) %>% 
                                  filter(year==2022, tt=="test", src!="Vegas"), 
                              isContVar=FALSE, 
                              returnData=TRUE
                              )
## Warning: Dropped unused factor level(s) in dependent variable: Vegas.
## Growing trees.. Progress: 65%. Estimated remaining time: 16 seconds.

## 
## Accuracy of test data is: 98.725%

predictRF(rfCityNoMoisture$rf, df=houTemp) %>% count(pred)
## # A tibble: 1 × 2
##   pred         n
##   <fct>    <int>
## 1 Houston 122712

The previously trained random forest models overwhelmingly predict Las Vegas as Los Angeles (if soil moisture is included) or Houston (if soil moisture is excluded)

The linear approximation for estimating temperature based on dewpoint and relative humidity is applied:

ggMiniTempLAS <- predict(lmMiniTemp, 
                         newdata=allCity %>% 
                             filter(src=="Vegas", tt=="test", year==2022) %>%
                             select(rh=relativehumidity_2m, d=dewpoint_2m)
                         ) %>% 
    mutate(allCity %>% filter(src=="Vegas", tt=="test", year==2022) %>% select(temperature_2m), 
           pred=., 
           err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
    ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean))
ggMiniTempLAS
## # A tibble: 11 × 6
##     rnd5     n temperature_2m   pred     err     err2
##    <dbl> <dbl>          <dbl>  <dbl>   <dbl>    <dbl>
##  1    -5     1          -2.7  -2.95   -0.252   0.0633
##  2     0    48           1.09  0.469  -0.616   2.42  
##  3     5   264           5.52  3.97   -1.55    6.82  
##  4    10   406           9.96  6.39   -3.56   23.1   
##  5    15   345          14.7   8.61   -6.11   54.3   
##  6    20   294          20.1  11.4    -8.65   98.2   
##  7    25   370          25.2  16.8    -8.41  110.    
##  8    30   407          29.8  20.4    -9.37  142.    
##  9    35   274          34.8  22.6   -12.3   202.    
## 10    40   119          39.7  23.1   -16.6   298.    
## 11    45     9          43.5  22.8   -20.7   430.
ggMiniTempLAS %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##     mse  rmse
##   <dbl> <dbl>
## 1  99.3  9.97
ggMiniTempLAS %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using Old City Linear Model on New City Data", 
         x="New city actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

The linear approximation based on dewpoint and relative humidity is inaccurate for predicting temperatures in Las Vegas, consistent with Las Vegas having T/D trends very different from originally modeled cities, NYC and Chicago

Las Vegas is meaningfully different from NYC and Chicago on key predictors:

tmpPlotData <- allCity %>% 
    select(src, relativehumidity_2m, dewpoint_2m, temperature_2m) %>% 
    mutate(across(where(is.numeric), .fns=round)) %>% 
    count(src, relativehumidity_2m, dewpoint_2m, temperature_2m)

tmpPlotData %>%
    count(src, temperature_2m, dewpoint_2m, wt=n) %>%
    ggplot(aes(x=temperature_2m, y=dewpoint_2m)) + 
    geom_point(aes(color=src, size=n), alpha=0.2) + 
    geom_smooth(aes(color=src, weight=n), method="lm") +
    labs(title="T/D by city")
## `geom_smooth()` using formula = 'y ~ x'

tmpPlotData %>%
    count(src, temperature_2m, relativehumidity_2m, wt=n) %>%
    ggplot(aes(x=temperature_2m, y=relativehumidity_2m)) + 
    geom_point(aes(color=src, size=n), alpha=0.1) + 
    geom_smooth(aes(color=src, weight=n), method="lm") +
    labs(title="T/RH by city")
## `geom_smooth()` using formula = 'y ~ x'

The existing random forest model, trained on NYC and Chicago, is also tested on Las Vegas temperatures:

# Temperature predictions for Vegas
runFullRF(yVar="temperature_2m", 
          useExistingRF=rfTemp2m$rf, 
          dfTest=allCity %>% filter(tt=="test", year==2022, src=="Vegas"), 
          useLabel="Las Vegas temperature predictions", 
          useSub="Las Vegas", 
          isContVar=TRUE,
          rndTo=0.5, 
          refXY=TRUE
          )
## 
## R-squared of Las Vegas temperature predictions is: 90.29% (RMSE 3.32 vs. 10.65 null)
## `geom_smooth()` using formula = 'y ~ x'

The random forest is more accurate than the linear model in predicting temperatures in Las Vegas based on training data from other cities. RMSE is ~3 rather than the ~10 from the linear model application

All combinations of two variables are explored for predicting temperature on a smaller training dataset:

# Train and test data
dfTrainTemp <- allCity %>% 
    filter(!(src %in% c("Vegas")), tt=="train", year<2022) %>% 
    mutate(fct_src=factor(src))
dfTestTemp <- allCity %>% 
    filter(!(src %in% c("Vegas")), tt=="test", year==2022) %>% 
    mutate(fct_src=factor(src))

# Variables to explore
possTempVars <- c(varsTrain[!str_detect(varsTrain, "^temp|ature$")], "month", "tod")

# Subsets to use
set.seed(24070815)
idxSmallTemp <- sample(1:nrow(dfTrainTemp), 5000, replace=FALSE)
mtxSmallTemp <- matrix(nrow=0, ncol=3)

for(idx1 in 1:(length(possTempVars)-1)) {
    for(idx2 in (idx1+1):length(possTempVars)) {
        r2SmallTemp <- runFullRF(dfTrain=dfTrainTemp[idxSmallTemp,], 
                                 yVar="temperature_2m", 
                                 xVars=possTempVars[c(idx1, idx2)], 
                                 dfTest=dfTestTemp, 
                                 useLabel=keyLabel, 
                                 useSub=stringr::str_to_sentence(keyLabel), 
                                 isContVar=TRUE,
                                 makePlots=FALSE,
                                 returnData=TRUE
                                 )[["rfAcc"]][["r2"]]
        mtxSmallTemp <- rbind(mtxSmallTemp, c(idx1, idx2, r2SmallTemp))
    }
}
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.429% (RMSE 9.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.568% (RMSE 5.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.904% (RMSE 8.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.761% (RMSE 9.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.887% (RMSE 10.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.689% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.11% (RMSE 9.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.088% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.741% (RMSE 9.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.102% (RMSE 9.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.91% (RMSE 10.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.741% (RMSE 8.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.008% (RMSE 9.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.981% (RMSE 9.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.124% (RMSE 9.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.458% (RMSE 10.01 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.166% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.926% (RMSE 10.03 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.027% (RMSE 10.03 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.149% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 40.99% (RMSE 7.99 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.581% (RMSE 9.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.066% (RMSE 7.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.913% (RMSE 2.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 88.307% (RMSE 3.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.703% (RMSE 5.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 34.437% (RMSE 8.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.273% (RMSE 9.74 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.693% (RMSE 9.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.371% (RMSE 9.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.175% (RMSE 10.13 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.815% (RMSE 10.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 55.027% (RMSE 6.98 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.472% (RMSE 6.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.346% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.67% (RMSE 0.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.088% (RMSE 9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.674% (RMSE 9.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.583% (RMSE 10.27 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.53% (RMSE 10.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.545% (RMSE 10.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.577% (RMSE 10.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.095% (RMSE 10.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.496% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.226% (RMSE 10.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.277% (RMSE 9.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.385% (RMSE 9.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.7% (RMSE 9.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.058% (RMSE 9.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.35% (RMSE 10.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.799% (RMSE 10.36 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.856% (RMSE 10.36 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.208% (RMSE 10.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.26% (RMSE 10.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 37.901% (RMSE 8.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.266% (RMSE 9.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 98.932% (RMSE 1.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.996% (RMSE 2.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 83.519% (RMSE 4.22 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.807% (RMSE 5.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.043% (RMSE 8.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.491% (RMSE 10.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.247% (RMSE 9.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.563% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.445% (RMSE 10.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.944% (RMSE 10.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.033% (RMSE 6.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 58.427% (RMSE 6.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.112% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.703% (RMSE 6.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 74.493% (RMSE 5.25 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.963% (RMSE 5.89 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 62.674% (RMSE 6.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 59.516% (RMSE 6.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 72.282% (RMSE 5.48 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 71.68% (RMSE 5.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.17% (RMSE 5.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.591% (RMSE 6.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 77.957% (RMSE 4.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.145% (RMSE 4.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 78.794% (RMSE 4.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.678% (RMSE 5.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.79% (RMSE 6.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.682% (RMSE 6.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.451% (RMSE 5.93 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.143% (RMSE 5.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.739% (RMSE 6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 88.916% (RMSE 3.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 72.176% (RMSE 5.49 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.885% (RMSE 0.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 95.287% (RMSE 2.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 84.311% (RMSE 4.12 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 77.826% (RMSE 4.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.575% (RMSE 5.74 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 75.127% (RMSE 5.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 72.572% (RMSE 5.45 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 60.311% (RMSE 6.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 72.894% (RMSE 5.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.081% (RMSE 6.23 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.822% (RMSE 5.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 71.887% (RMSE 5.51 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 62.518% (RMSE 6.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 78.956% (RMSE 4.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.745% (RMSE 8.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.842% (RMSE 9.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.151% (RMSE 8.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.112% (RMSE 8.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.85% (RMSE 8.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.306% (RMSE 8.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.438% (RMSE 9.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 35.883% (RMSE 8.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 36.09% (RMSE 8.31 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 33.366% (RMSE 8.49 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.024% (RMSE 8.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.767% (RMSE 9.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.717% (RMSE 9.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.207% (RMSE 9.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.618% (RMSE 9.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.859% (RMSE 9.25 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.139% (RMSE 7.63 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.623% (RMSE 8.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.748% (RMSE 6.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.979% (RMSE 2.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.88% (RMSE 4.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 70.025% (RMSE 5.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.042% (RMSE 7.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.374% (RMSE 9.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.767% (RMSE 9.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.334% (RMSE 9.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.753% (RMSE 9.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.253% (RMSE 9.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.238% (RMSE 7.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 55.056% (RMSE 6.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.286% (RMSE 8.93 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.817% (RMSE 9.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.3% (RMSE 9.74 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.245% (RMSE 9.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.25% (RMSE 9.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.46% (RMSE 9.45 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.289% (RMSE 9.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.55% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.526% (RMSE 8.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.502% (RMSE 8.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.704% (RMSE 9.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.106% (RMSE 9.12 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.484% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.298% (RMSE 9.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.56% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.027% (RMSE 9.87 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.633% (RMSE 9.89 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 40.008% (RMSE 8.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.242% (RMSE 9.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 55.477% (RMSE 6.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.082% (RMSE 2.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.986% (RMSE 4.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 68.676% (RMSE 5.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 36.736% (RMSE 8.27 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.046% (RMSE 9.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.806% (RMSE 9.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.218% (RMSE 9.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.571% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.86% (RMSE 9.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.211% (RMSE 6.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 58.768% (RMSE 6.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.445% (RMSE 9.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.088% (RMSE 10.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.043% (RMSE 10.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.587% (RMSE 10.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.672% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.859% (RMSE 9.87 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.948% (RMSE 10.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.057% (RMSE 9.47 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.875% (RMSE 9.48 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.887% (RMSE 9.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.131% (RMSE 9.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.397% (RMSE 10.28 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.15% (RMSE 10.13 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.72% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.77% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.215% (RMSE 10.41 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.147% (RMSE 8.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.585% (RMSE 10.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.717% (RMSE 7.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.485% (RMSE 2.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.222% (RMSE 4.74 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.135% (RMSE 6.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.954% (RMSE 8.7 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.324% (RMSE 9.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.715% (RMSE 9.99 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.122% (RMSE 10.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.423% (RMSE 10.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.41% (RMSE 10.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.009% (RMSE 7.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.983% (RMSE 7.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.19% (RMSE 10.23 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.913% (RMSE 10.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.521% (RMSE 10.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.228% (RMSE 10.18 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.842% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.242% (RMSE 10.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.786% (RMSE 9.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.899% (RMSE 9.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.622% (RMSE 9.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.202% (RMSE 9.8 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.261% (RMSE 10.23 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.787% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.425% (RMSE 10.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.516% (RMSE 10.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.949% (RMSE 10.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.915% (RMSE 8.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.8% (RMSE 10.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.522% (RMSE 7.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 82.046% (RMSE 4.41 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 71.623% (RMSE 5.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 59.81% (RMSE 6.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.356% (RMSE 8.8 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.174% (RMSE 9.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.885% (RMSE 10.04 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.068% (RMSE 10.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.175% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.351% (RMSE 10.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.321% (RMSE 7.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.513% (RMSE 7.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.181% (RMSE 10.23 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.207% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.276% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.164% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.696% (RMSE 10.15 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.841% (RMSE 9.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.143% (RMSE 9.47 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.715% (RMSE 9.66 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.786% (RMSE 9.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.242% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.538% (RMSE 9.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.678% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.324% (RMSE 9.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.554% (RMSE 10.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.586% (RMSE 8.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.349% (RMSE 10.12 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 40.067% (RMSE 8.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.189% (RMSE 4.63 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.093% (RMSE 5.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 58.81% (RMSE 6.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.071% (RMSE 8.76 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.24% (RMSE 9.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.185% (RMSE 9.91 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.289% (RMSE 10.12 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.112% (RMSE 9.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.54% (RMSE 10.22 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.685% (RMSE 7.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 40.754% (RMSE 8.01 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.191% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.731% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.638% (RMSE 9.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.92% (RMSE 10.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.027% (RMSE 9.47 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.557% (RMSE 9.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.768% (RMSE 9.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.424% (RMSE 9.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.623% (RMSE 10.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.59% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.906% (RMSE 10.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.942% (RMSE 10.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.691% (RMSE 10.36 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.532% (RMSE 8.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.065% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.031% (RMSE 7.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.521% (RMSE 2.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.598% (RMSE 4.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.12% (RMSE 5.96 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.263% (RMSE 8.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.47% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.16% (RMSE 9.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.485% (RMSE 9.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.039% (RMSE 10.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.357% (RMSE 10.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.638% (RMSE 7.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.487% (RMSE 7.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.102% (RMSE 9.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.189% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.59% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.264% (RMSE 9.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.97% (RMSE 9.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.181% (RMSE 9.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.948% (RMSE 9.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.675% (RMSE 10.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.074% (RMSE 10.13 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.891% (RMSE 10.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.19% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.818% (RMSE 10.36 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.005% (RMSE 8.7 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.852% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.358% (RMSE 7.47 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.347% (RMSE 2.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.012% (RMSE 4.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.953% (RMSE 6.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.794% (RMSE 8.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.705% (RMSE 9.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.2% (RMSE 9.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.392% (RMSE 9.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.316% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.699% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.662% (RMSE 7.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.94% (RMSE 7.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.523% (RMSE 10.06 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.773% (RMSE 9.99 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.936% (RMSE 9.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.686% (RMSE 9.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.661% (RMSE 9.44 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.668% (RMSE 9.38 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.026% (RMSE 9.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.733% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.329% (RMSE 9.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.428% (RMSE 9.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.042% (RMSE 10.03 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 33.997% (RMSE 8.45 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.921% (RMSE 9.65 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.934% (RMSE 7.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 91.474% (RMSE 3.04 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.676% (RMSE 4.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.358% (RMSE 5.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 33.489% (RMSE 8.48 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.825% (RMSE 9.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.482% (RMSE 9.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.046% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.669% (RMSE 9.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.469% (RMSE 9.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.054% (RMSE 7.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.255% (RMSE 7.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.485% (RMSE 9.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.672% (RMSE 9.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.964% (RMSE 9.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.018% (RMSE 9.81 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.516% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.288% (RMSE 10.39 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.913% (RMSE 10.25 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.019% (RMSE 10.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.434% (RMSE 10.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.001% (RMSE 10.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.883% (RMSE 8.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.572% (RMSE 10 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 42.916% (RMSE 7.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 88.409% (RMSE 3.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 77.112% (RMSE 4.98 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.798% (RMSE 6.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.508% (RMSE 8.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.756% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.603% (RMSE 10.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.627% (RMSE 10.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.687% (RMSE 10.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.273% (RMSE 10.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 44.735% (RMSE 7.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.03% (RMSE 7.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.086% (RMSE 10.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.677% (RMSE 9.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.621% (RMSE 9.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.785% (RMSE 9.66 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.877% (RMSE 9.48 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.718% (RMSE 9.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.868% (RMSE 9.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.49% (RMSE 9.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.479% (RMSE 9.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.869% (RMSE 7.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.992% (RMSE 9.19 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.596% (RMSE 7.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.366% (RMSE 2.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 87.954% (RMSE 3.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 75.429% (RMSE 5.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 45.403% (RMSE 7.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.699% (RMSE 9.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.297% (RMSE 9.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.315% (RMSE 9.51 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.759% (RMSE 9.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.278% (RMSE 9.63 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.03% (RMSE 6.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.971% (RMSE 6.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.862% (RMSE 9.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.844% (RMSE 9.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.169% (RMSE 9.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.689% (RMSE 9.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.163% (RMSE 9.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.585% (RMSE 9.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.932% (RMSE 9.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.104% (RMSE 9.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.787% (RMSE 7.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.386% (RMSE 9.22 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.94% (RMSE 7.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.855% (RMSE 2.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 88.061% (RMSE 3.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 75.203% (RMSE 5.18 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 44.167% (RMSE 7.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.851% (RMSE 9.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.851% (RMSE 9.31 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.322% (RMSE 9.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.277% (RMSE 9.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.266% (RMSE 9.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 55.637% (RMSE 6.93 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.908% (RMSE 6.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.073% (RMSE 9.47 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.719% (RMSE 9.66 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.731% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.305% (RMSE 9.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.25% (RMSE 9.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.522% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.422% (RMSE 9.84 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 38.267% (RMSE 8.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.695% (RMSE 9.44 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.747% (RMSE 7.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.935% (RMSE 2.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 87.475% (RMSE 3.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.738% (RMSE 5.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 38.936% (RMSE 8.13 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.704% (RMSE 9.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.667% (RMSE 9.44 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.314% (RMSE 9.68 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.882% (RMSE 9.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.244% (RMSE 9.8 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 54.438% (RMSE 7.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.275% (RMSE 6.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.786% (RMSE 9.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.431% (RMSE 9.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.527% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.667% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.917% (RMSE 9.76 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.841% (RMSE 9.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 33.882% (RMSE 8.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.762% (RMSE 9.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 45.646% (RMSE 7.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.171% (RMSE 2.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 86.649% (RMSE 3.8 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.192% (RMSE 5.39 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.825% (RMSE 7.93 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.773% (RMSE 9.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.767% (RMSE 9.49 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.47% (RMSE 9.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.618% (RMSE 9.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.914% (RMSE 9.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 52.493% (RMSE 7.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 54.696% (RMSE 7 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.165% (RMSE 9.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.291% (RMSE 10.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.954% (RMSE 10.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.332% (RMSE 10.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.1% (RMSE 10.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 33.903% (RMSE 8.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.123% (RMSE 9.97 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.542% (RMSE 7.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.665% (RMSE 2.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.68% (RMSE 4.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.732% (RMSE 6.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.843% (RMSE 9.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.725% (RMSE 10.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.505% (RMSE 10.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.44% (RMSE 10.38 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.633% (RMSE 10.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.062% (RMSE 10.35 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.063% (RMSE 7.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.964% (RMSE 7.21 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.182% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.131% (RMSE 10.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.786% (RMSE 10.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.983% (RMSE 10.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.804% (RMSE 8.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.402% (RMSE 9.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 44.643% (RMSE 7.74 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.705% (RMSE 2.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.142% (RMSE 4.63 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.855% (RMSE 6.08 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.35% (RMSE 8.99 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.672% (RMSE 10.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.579% (RMSE 10.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.524% (RMSE 10.27 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.096% (RMSE 10.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.885% (RMSE 10.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.1% (RMSE 7.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.588% (RMSE 7.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.393% (RMSE 9.95 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.371% (RMSE 10.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.714% (RMSE 10.49 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.888% (RMSE 8.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.623% (RMSE 9.78 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.561% (RMSE 7.81 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.832% (RMSE 2.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 81.837% (RMSE 4.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 68.57% (RMSE 5.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.745% (RMSE 8.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.956% (RMSE 10.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.741% (RMSE 10.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.074% (RMSE 10.4 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.185% (RMSE 10.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.327% (RMSE 10.17 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.74% (RMSE 7.3 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 53.287% (RMSE 7.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.992% (RMSE 9.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.754% (RMSE 10.44 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.618% (RMSE 8.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.681% (RMSE 9.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.891% (RMSE 7.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.861% (RMSE 2.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 82.013% (RMSE 4.41 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 68.121% (RMSE 5.87 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.831% (RMSE 8.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.142% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.857% (RMSE 10.04 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.315% (RMSE 10.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.64% (RMSE 10.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.713% (RMSE 10.15 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.573% (RMSE 7.39 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 52.879% (RMSE 7.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.715% (RMSE 9.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.923% (RMSE 8.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.109% (RMSE 10.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.701% (RMSE 7.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.65% (RMSE 2.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 81.967% (RMSE 4.42 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.596% (RMSE 5.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.377% (RMSE 8.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.408% (RMSE 10.38 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.302% (RMSE 10.23 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.066% (RMSE 10.4 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.751% (RMSE 10.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.995% (RMSE 10.45 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.51% (RMSE 7.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.323% (RMSE 7.26 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.276% (RMSE 10.12 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 34.362% (RMSE 8.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 54.634% (RMSE 7.01 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.115% (RMSE 2.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 89.72% (RMSE 3.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 78.969% (RMSE 4.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 52.809% (RMSE 7.14 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.763% (RMSE 8.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 34.305% (RMSE 8.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.562% (RMSE 8.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.478% (RMSE 8.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.885% (RMSE 8.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.747% (RMSE 6.09 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.572% (RMSE 6.01 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.948% (RMSE 8.71 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.827% (RMSE 7.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.636% (RMSE 2.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.757% (RMSE 4.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.744% (RMSE 5.91 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.76% (RMSE 8.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.877% (RMSE 9.6 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.606% (RMSE 9.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.554% (RMSE 9.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.801% (RMSE 9.88 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.244% (RMSE 10.07 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.584% (RMSE 7.31 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.405% (RMSE 7.32 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.579% (RMSE 9.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 95.146% (RMSE 2.29 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 89.291% (RMSE 3.4 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.955% (RMSE 4.66 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 60.074% (RMSE 6.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.112% (RMSE 7.49 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.738% (RMSE 7.3 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.973% (RMSE 7.57 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.898% (RMSE 7.79 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.974% (RMSE 7.92 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 71.973% (RMSE 5.51 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 72.739% (RMSE 5.43 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 41.766% (RMSE 7.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.139% (RMSE 2.52 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.978% (RMSE 2.55 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.809% (RMSE 2.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.028% (RMSE 2.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.726% (RMSE 2.61 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.291% (RMSE 2.69 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.555% (RMSE 2.64 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 91.044% (RMSE 3.11 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.807% (RMSE 2.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.102% (RMSE 2.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.584% (RMSE 4.58 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.924% (RMSE 4.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.24% (RMSE 4.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.578% (RMSE 4.7 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.431% (RMSE 4.72 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.301% (RMSE 4.73 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 78.716% (RMSE 4.8 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.109% (RMSE 4.75 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 79.81% (RMSE 4.67 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 80.973% (RMSE 4.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 75.944% (RMSE 5.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 70.843% (RMSE 5.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.566% (RMSE 6.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.709% (RMSE 6.18 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 61.436% (RMSE 6.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 62.479% (RMSE 6.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.558% (RMSE 6.1 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 70.774% (RMSE 5.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 73.489% (RMSE 5.36 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 60.888% (RMSE 6.5 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.533% (RMSE 8.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.923% (RMSE 8.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.66% (RMSE 9.15 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.347% (RMSE 9.51 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.933% (RMSE 8.83 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 69.27% (RMSE 5.77 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 71.425% (RMSE 5.56 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.27% (RMSE 8.62 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.58% (RMSE 9.03 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.775% (RMSE 9.37 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 29.102% (RMSE 8.76 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.178% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 52.943% (RMSE 7.13 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.017% (RMSE 6.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.833% (RMSE 9.82 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.51% (RMSE 9.89 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.762% (RMSE 8.53 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.111% (RMSE 9.86 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.187% (RMSE 7.34 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 54.482% (RMSE 7.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.489% (RMSE 9.9 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.092% (RMSE 8.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.979% (RMSE 10.66 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 40.538% (RMSE 8.02 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.519% (RMSE 7.46 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.702% (RMSE 10.15 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.641% (RMSE 10.59 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.967% (RMSE 5.98 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.189% (RMSE 6.05 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.567% (RMSE 9.89 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.239% (RMSE 7.63 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.407% (RMSE 7.54 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.068% (RMSE 10.24 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.415% (RMSE 7.25 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 42.973% (RMSE 7.85 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 42.357% (RMSE 7.9 vs. 10.4 null)

Predictive success by metric is explored:

dfSmallR2Temp <- as.data.frame(mtxSmallTemp) %>% 
    purrr::set_names(c("idx1", "idx2", "r2")) %>% 
    tibble::as_tibble() %>% 
    mutate(var1=possTempVars[idx1], var2=possTempVars[idx2], rn=row_number()) 
dfSmallR2Temp %>% arrange(desc(r2)) %>% select(var1, var2, r2) %>% print(n=20)
## # A tibble: 630 × 3
##    var1                       var2                             r2
##    <chr>                      <chr>                         <dbl>
##  1 dewpoint_2m                vapor_pressure_deficit        0.999
##  2 relativehumidity_2m        dewpoint_2m                   0.997
##  3 relativehumidity_2m        vapor_pressure_deficit        0.989
##  4 dewpoint_2m                soil_temperature_0_to_7cm     0.953
##  5 vapor_pressure_deficit     soil_temperature_0_to_7cm     0.951
##  6 soil_temperature_0_to_7cm  soil_temperature_7_to_28cm    0.941
##  7 et0_fao_evapotranspiration soil_temperature_0_to_7cm     0.941
##  8 surface_pressure           soil_temperature_0_to_7cm     0.941
##  9 soil_temperature_0_to_7cm  soil_moisture_0_to_7cm        0.940
## 10 relativehumidity_2m        soil_temperature_0_to_7cm     0.940
## 11 pressure_msl               soil_temperature_0_to_7cm     0.940
## 12 soil_temperature_0_to_7cm  soil_temperature_28_to_100cm  0.940
## 13 direct_normal_irradiance   soil_temperature_0_to_7cm     0.939
## 14 hour                       soil_temperature_0_to_7cm     0.939
## 15 winddirection_100m         soil_temperature_0_to_7cm     0.939
## 16 direct_radiation           soil_temperature_0_to_7cm     0.939
## 17 winddirection_10m          soil_temperature_0_to_7cm     0.938
## 18 soil_temperature_0_to_7cm  soil_temperature_100_to_255cm 0.938
## 19 soil_temperature_0_to_7cm  doy                           0.938
## 20 soil_temperature_0_to_7cm  soil_moisture_7_to_28cm       0.937
## # ℹ 610 more rows
dfSmallR2Temp %>% 
    pivot_longer(cols=c(var1, var2)) %>% 
    group_by(value) %>% 
    summarize(across(r2, .fns=list("min"=min, "mu"=mean, "max"=max))) %>% 
    ggplot(aes(x=fct_reorder(value, r2_mu))) + 
    coord_flip() + 
    geom_point(aes(y=r2_mu)) + 
    geom_errorbar(aes(ymin=r2_min, ymax=r2_max)) + 
    lims(y=c(NA, 1)) + 
    geom_hline(yintercept=1, lty=2, color="red") +
    labs(title="R-squared in every 2-predictor model including self and one other", 
         subtitle="Predicting temperature", 
         y="Range of R-squared (min-mean-max)", 
         x=NULL
    )

dfSmallR2Temp %>% 
    arrange(desc(r2)) %>% 
    filter(var2!="soil_temperature_0_to_7cm", var1!="soil_temperature_0_to_7cm") %>% 
    select(var1, var2, r2) %>% 
    print(n=20)
## # A tibble: 595 × 3
##    var1                       var2                            r2
##    <chr>                      <chr>                        <dbl>
##  1 dewpoint_2m                vapor_pressure_deficit       0.999
##  2 relativehumidity_2m        dewpoint_2m                  0.997
##  3 relativehumidity_2m        vapor_pressure_deficit       0.989
##  4 et0_fao_evapotranspiration soil_temperature_7_to_28cm   0.897
##  5 vapor_pressure_deficit     soil_temperature_7_to_28cm   0.893
##  6 dewpoint_2m                et0_fao_evapotranspiration   0.889
##  7 hour                       soil_temperature_7_to_28cm   0.883
##  8 direct_radiation           soil_temperature_7_to_28cm   0.881
##  9 shortwave_radiation        soil_temperature_7_to_28cm   0.880
## 10 direct_normal_irradiance   soil_temperature_7_to_28cm   0.875
## 11 diffuse_radiation          soil_temperature_7_to_28cm   0.866
## 12 dewpoint_2m                soil_temperature_7_to_28cm   0.843
## 13 relativehumidity_2m        soil_temperature_7_to_28cm   0.835
## 14 winddirection_100m         soil_temperature_7_to_28cm   0.820
## 15 windgusts_10m              soil_temperature_7_to_28cm   0.820
## 16 winddirection_10m          soil_temperature_7_to_28cm   0.818
## 17 surface_pressure           soil_temperature_7_to_28cm   0.810
## 18 soil_temperature_7_to_28cm month                        0.810
## 19 soil_temperature_7_to_28cm soil_temperature_28_to_100cm 0.809
## 20 pressure_msl               soil_temperature_7_to_28cm   0.809
## # ℹ 575 more rows

Select combinations are explored using the full training dataset:

possLargeVars <- c("dewpoint_2m", 
                   "vapor_pressure_deficit", 
                   "relativehumidity_2m", 
                   "soil_temperature_0_to_7cm"
                   )
possLargeVars
## [1] "dewpoint_2m"               "vapor_pressure_deficit"   
## [3] "relativehumidity_2m"       "soil_temperature_0_to_7cm"
mtxLarge <- matrix(nrow=0, ncol=3)

for(idx1 in 1:(length(possLargeVars)-1)) {
    for(idx2 in (idx1+1):length(possLargeVars)) {
        r2LargeTemp <- runFullRF(dfTrain=dfTrainTemp[,], 
                                 yVar="temperature_2m", 
                                 xVars=possLargeVars[c(idx1, idx2)], 
                                 dfTest=dfTestTemp, 
                                 useLabel=keyLabel, 
                                 useSub=stringr::str_to_sentence(keyLabel), 
                                 isContVar=TRUE,
                                 makePlots=FALSE,
                                 returnData=TRUE
                                 )[["rfAcc"]][["r2"]]
        mtxLarge <- rbind(mtxLarge, c(idx1, idx2, r2LargeTemp))
    }
}
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.964% (RMSE 0.2 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.902% (RMSE 0.33 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 95.675% (RMSE 2.16 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.177% (RMSE 0.94 vs. 10.4 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 95.59% (RMSE 2.18 vs. 10.4 null)
## Growing trees.. Progress: 91%. Estimated remaining time: 2 seconds.
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.588% (RMSE 2.42 vs. 10.4 null)
dfLargeR2Temp <- as.data.frame(mtxLarge) %>% 
    purrr::set_names(c("idx1", "idx2", "r2")) %>% 
    tibble::as_tibble() %>% 
    mutate(var1=possLargeVars[idx1], var2=possLargeVars[idx2], rn=row_number()) 
dfLargeR2Temp %>% arrange(desc(r2)) %>% select(var1, var2, r2) %>% print(n=20)
## # A tibble: 6 × 3
##   var1                   var2                         r2
##   <chr>                  <chr>                     <dbl>
## 1 dewpoint_2m            vapor_pressure_deficit    1.00 
## 2 dewpoint_2m            relativehumidity_2m       0.999
## 3 vapor_pressure_deficit relativehumidity_2m       0.992
## 4 dewpoint_2m            soil_temperature_0_to_7cm 0.957
## 5 vapor_pressure_deficit soil_temperature_0_to_7cm 0.956
## 6 relativehumidity_2m    soil_temperature_0_to_7cm 0.946

A model using only dewpoint and vapor pressure deficit is run on one city, then applied to the other:

# Train and test data
dfTrainTemp_v2 <- allCity %>% 
    filter(src %in% c("NYC"), tt=="train", year<2022) %>% 
    mutate(fct_src=factor(src))
dfTestTemp_v2 <- allCity %>% 
    filter(tt=="test", year==2022) %>% 
    mutate(fct_src=factor(src))

# Random forest for temperature using dewpoint and vapor pressure deficit
keyLabel <- "predictions based on NYC pre-2022 training data applied to each city in 2022 holdout dataset"
tmpPred_v2 <- runFullRF(dfTrain=dfTrainTemp_v2, 
                        yVar="temperature_2m", 
                        xVars=c("dewpoint_2m", "vapor_pressure_deficit"), 
                        dfTest=dfTestTemp_v2, 
                        useLabel=keyLabel, 
                        useSub=stringr::str_to_sentence(keyLabel), 
                        isContVar=TRUE,
                        makePlots=FALSE,
                        returnData=TRUE
                        )[["tstPred"]] %>%
    select(src, temperature_2m, pred) %>%
    group_by(src) %>%
    summarize(n=n(), 
              tss=sum((temperature_2m-mean(temperature_2m))**2), 
              rss=sum((temperature_2m-pred)**2), 
              r2=1-rss/tss, 
              rmse=sqrt(rss/n),
              berr=sqrt(tss/n)
              )
## 
## R-squared of predictions based on NYC pre-2022 training data applied to each city in 2022 holdout dataset is: 94.65% (RMSE 2.47 vs. 10.69 null)
tmpPred_v2
## # A tibble: 5 × 7
##   src         n     tss    rss    r2  rmse  berr
##   <chr>   <int>   <dbl>  <dbl> <dbl> <dbl> <dbl>
## 1 Chicago  2592 356174.   305. 0.999 0.343 11.7 
## 2 Houston  2659 194789.   400. 0.998 0.388  8.56
## 3 LA       2677 127962.  6718. 0.947 1.58   6.91
## 4 NYC      2664 280171.   104. 1.00  0.197 10.3 
## 5 Vegas    2537 287670. 72697. 0.747 5.35  10.6

The model trained on NYC performs well on Chicago, Houston, and LA, while missing significantly on Las Vegas

Patterns in dewpoint and vapor pressure deficit are explored:

dfPlot_v2 <- dfTestTemp_v2 %>% 
    select(src, vapor_pressure_deficit, dewpoint_2m) %>% 
    mutate(across(where(is.numeric), .fns=function(x) round(2*x)/2)) %>% 
    count(src, vapor_pressure_deficit, dewpoint_2m) 

dfPlot_v2 %>% 
    ggplot(aes(y=vapor_pressure_deficit, x=dewpoint_2m)) + 
    geom_point(aes(color=src, size=n), alpha=0.25) + facet_wrap(~src) + 
    scale_color_discrete(NULL)

# Overlap of NYC points by city
tmpNYC <- dfTrainTemp_v2 %>% 
    select(src, vapor_pressure_deficit, dewpoint_2m) %>% 
    mutate(across(where(is.numeric), .fns=function(x) round(2*x)/2)) %>% 
    count(src, vapor_pressure_deficit, dewpoint_2m) %>%
    filter(src=="NYC", n>=10) %>%
    mutate(inNYC=TRUE)

dfPlot_v2 %>%
    left_join(select(tmpNYC, vapor_pressure_deficit, dewpoint_2m, inNYC), 
              by=c("vapor_pressure_deficit", "dewpoint_2m")
              ) %>%
    mutate(inNYC=ifelse(is.na(inNYC), FALSE, inNYC)) %>% 
    ggplot(aes(y=vapor_pressure_deficit, x=dewpoint_2m)) + 
    geom_point(aes(color=inNYC, size=n), alpha=0.25) + facet_wrap(~src) + 
    scale_color_discrete("NYC training\nhas 10+ obs")

dfPlot_v2 %>%
    left_join(select(tmpNYC, vapor_pressure_deficit, dewpoint_2m, inNYC), 
              by=c("vapor_pressure_deficit", "dewpoint_2m")
              ) %>%
    mutate(inNYC=ifelse(is.na(inNYC), FALSE, inNYC)) %>%
    group_by(src) %>%
    summarize(meanNYC=sum(n*inNYC)/sum(n), n=sum(n), nObs=n())
## # A tibble: 5 × 4
##   src     meanNYC     n  nObs
##   <chr>     <dbl> <int> <int>
## 1 Chicago   0.988  2592   335
## 2 Houston   0.936  2659   371
## 3 LA        0.802  2677   490
## 4 NYC       0.990  2664   361
## 5 Vegas     0.355  2537   747

Chicago and NYC are both very well-represented by the training data, while a majority of Las Vegas observations are largely or entirely absent from the training data

There are strong relationships among dewpoint, vapor pressure deficit, relative humidity, and temperature:

dfTestTemp_v2 %>% 
    select(src, vapor_pressure_deficit, dewpoint_2m, temperature_2m, relativehumidity_2m) %>% 
    mutate(across(c(dewpoint_2m, temperature_2m, relativehumidity_2m), .fns=function(x) round(x))) %>% 
    filter(dewpoint_2m %in% c(-10, 0, 10, 20)) %>% 
    ggplot(aes(x=vapor_pressure_deficit, y=temperature_2m)) + 
    geom_point(aes(color=factor(dewpoint_2m))) + 
    scale_color_discrete("Dewpoint")

dfTestTemp_v2 %>% 
    select(src, vapor_pressure_deficit, dewpoint_2m, temperature_2m, relativehumidity_2m) %>% 
    mutate(across(c(dewpoint_2m, temperature_2m, relativehumidity_2m), .fns=function(x) round(x))) %>% 
    filter(dewpoint_2m %in% c(-10, 0, 10, 20)) %>% 
    ggplot(aes(x=relativehumidity_2m, y=temperature_2m)) + 
    geom_point(aes(color=factor(dewpoint_2m))) + 
    scale_color_discrete("Dewpoint")

To better cover the predictor space, a model using only dewpoint and vapor pressure deficit is run on NYC and Vegas, then applied to the others:

# Train and test data
dfTrainTemp_v3 <- allCity %>% 
    filter(src %in% c("NYC", "Vegas"), tt=="train", year<2022) %>% 
    mutate(fct_src=factor(src))
dfTestTemp_v3 <- allCity %>% 
    filter(tt=="test", year==2022) %>% 
    mutate(fct_src=factor(src))

# Random forest for temperature using dewpoint and vapor pressure deficit
keyLabel <- "predictions based on NYC/Vegas pre-2022 training data applied to each city in 2022 holdout dataset"
tmpPred_v3 <- runFullRF(dfTrain=dfTrainTemp_v3, 
                        yVar="temperature_2m", 
                        xVars=c("dewpoint_2m", "vapor_pressure_deficit"), 
                        dfTest=dfTestTemp_v3, 
                        useLabel=keyLabel, 
                        useSub=stringr::str_to_sentence(keyLabel), 
                        isContVar=TRUE,
                        makePlots=FALSE,
                        returnData=TRUE
                        )[["tstPred"]] %>%
    select(src, temperature_2m, pred) %>%
    group_by(src) %>%
    summarize(n=n(), 
              tss=sum((temperature_2m-mean(temperature_2m))**2), 
              rss=sum((temperature_2m-pred)**2), 
              r2=1-rss/tss, 
              rmse=sqrt(rss/n),
              berr=sqrt(tss/n)
              )
## 
## R-squared of predictions based on NYC/Vegas pre-2022 training data applied to each city in 2022 holdout dataset is: 99.959% (RMSE 0.22 vs. 10.69 null)
tmpPred_v3
## # A tibble: 5 × 7
##   src         n     tss   rss    r2  rmse  berr
##   <chr>   <int>   <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Chicago  2592 356174. 213.  0.999 0.287 11.7 
## 2 Houston  2659 194789. 258.  0.999 0.312  8.56
## 3 LA       2677 127962.  34.5 1.00  0.113  6.91
## 4 NYC      2664 280171.  66.4 1.00  0.158 10.3 
## 5 Vegas    2537 287670.  43.8 1.00  0.131 10.6

The model trained on NYC and Vegas generally performs very well on all cities

Coverage of the temperature and humidity space by city is explored:

dfTestTemp_v2 %>% 
    select(src, vapor_pressure_deficit, dewpoint_2m, temperature_2m, relativehumidity_2m) %>% 
    mutate(across(c(dewpoint_2m, temperature_2m, relativehumidity_2m), .fns=function(x) round(x))) %>% 
    ggplot(aes(x=dewpoint_2m, y=temperature_2m)) + 
    geom_density2d(data=~filter(., src %in% c("NYC", "Vegas"))) +
    geom_point(data=~count(., src, temperature_2m, dewpoint_2m), 
               aes(color=src, size=n), 
               alpha=0.25
               ) + 
    scale_color_discrete(NULL) + 
    labs(title="Relationships between temperature and depoint", 
         subtitle="Contours from geom_density_2d() use only NYC and Las Vegas data"
         )

Modeling using NYC and Las Vegas data may not fully cover the coldest and driest portions of the Chicago space

The model using only NYC and Las Vegas is applied to Chicago, with accuracy explored by temperature:

# Train and test data
dfTrainTemp_v3 <- allCity %>% 
    filter(src %in% c("NYC", "Vegas"), tt=="train", year<2022) %>% 
    mutate(fct_src=factor(src))
dfTestTemp_v3 <- allCity %>% 
    filter(tt=="test", year==2022) %>% 
    mutate(fct_src=factor(src))

# Random forest for temperature using dewpoint and vapor pressure deficit
keyLabel <- "predictions based on NYC/Vegas pre-2022 training data applied to each city in 2022 holdout dataset"
tmpPred_v3_df <- runFullRF(dfTrain=dfTrainTemp_v3, 
                           yVar="temperature_2m", 
                           xVars=c("dewpoint_2m", "vapor_pressure_deficit"), 
                           dfTest=dfTestTemp_v3, 
                           useLabel=keyLabel, 
                           useSub=stringr::str_to_sentence(keyLabel), 
                           isContVar=TRUE,
                           makePlots=FALSE,
                           returnData=TRUE
                           )[["tstPred"]] 
## 
## R-squared of predictions based on NYC/Vegas pre-2022 training data applied to each city in 2022 holdout dataset is: 99.959% (RMSE 0.22 vs. 10.69 null)
tmpPred_v3_df %>%
    select(src, temperature_2m, pred) %>%
    group_by(src) %>%
    summarize(n=n(), 
              tss=sum((temperature_2m-mean(temperature_2m))**2), 
              rss=sum((temperature_2m-pred)**2), 
              r2=1-rss/tss, 
              rmse=sqrt(rss/n),
              berr=sqrt(tss/n)
              )
## # A tibble: 5 × 7
##   src         n     tss   rss    r2  rmse  berr
##   <chr>   <int>   <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Chicago  2592 356174. 242.  0.999 0.305 11.7 
## 2 Houston  2659 194789. 228.  0.999 0.293  8.56
## 3 LA       2677 127962.  34.6 1.00  0.114  6.91
## 4 NYC      2664 280171.  64.1 1.00  0.155 10.3 
## 5 Vegas    2537 287670.  42.3 1.00  0.129 10.6
ggMiniTempCHI <- tmpPred_v3_df %>% 
    select(src, temperature_2m, pred) %>%
    filter(src=="Chicago") %>%
    mutate(err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
    ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean)) %>%
    mutate(pcterr2=n*err2/sum(n*err2))
ggMiniTempCHI
## # A tibble: 13 × 7
##     rnd5     n temperature_2m    pred      err     err2 pcterr2
##    <dbl> <dbl>          <dbl>   <dbl>    <dbl>    <dbl>   <dbl>
##  1   -25     2        -24.0   -16.4    7.70    59.4     0.491  
##  2   -20    19        -19.0   -17.6    1.34     2.54    0.200  
##  3   -15    43        -14.3   -14.0    0.333    0.164   0.0291 
##  4   -10   129         -9.94   -9.72   0.223    0.0970  0.0518 
##  5    -5   247         -4.80   -4.61   0.188    0.0720  0.0736 
##  6     0   321          0.192   0.269  0.0766   0.0239  0.0317 
##  7     5   356          4.69    4.69   0.00503  0.0119  0.0175 
##  8    10   284          9.82    9.79  -0.0294   0.0253  0.0298 
##  9    15   308         14.9    14.9   -0.00369  0.00893 0.0114 
## 10    20   480         20.2    20.1   -0.0391   0.0106  0.0210 
## 11    25   303         24.6    24.6   -0.0730   0.0236  0.0295 
## 12    30    90         29.1    29.0   -0.0939   0.0260  0.00969
## 13    35    10         34.7    34.4   -0.270    0.105   0.00435
ggMiniTempCHI %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##      mse  rmse
##    <dbl> <dbl>
## 1 0.0933 0.305
ggMiniTempCHI %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using NYC/Vegas Random Forest Model on Chicago Data", 
         x="Chicago actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

As expected, predictions are excellent in the space covered by the training data and poor for the small number of very cold observations never seen in training. Around 60% of MSE in Chicago temperature predictions occurs in the 23 test data observations where temperature (rounded to nearest 5 degrees C) is -20C or colder

The model using only NYC and Las Vegas is applied to Houston, with accuracy explored by temperature:

ggMiniTempHOU <- tmpPred_v3_df %>% 
    select(src, temperature_2m, pred) %>%
    filter(src=="Houston") %>%
    mutate(err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
    ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean)) %>%
    mutate(pcterr2=n*err2/sum(n*err2))
ggMiniTempHOU
## # A tibble: 11 × 7
##     rnd5     n temperature_2m   pred      err    err2  pcterr2
##    <dbl> <dbl>          <dbl>  <dbl>    <dbl>   <dbl>    <dbl>
##  1   -10     2         -8.15  -7.88   0.270   0.103   0.000904
##  2    -5    12         -3.8   -3.57   0.233   0.0711  0.00374 
##  3     0    44          0.448  0.497  0.0490  0.0190  0.00366 
##  4     5   179          5.44   5.43  -0.00674 0.00870 0.00682 
##  5    10   304         10.0   10.0   -0.0150  0.0183  0.0243  
##  6    15   279         15.1   15.1   -0.0164  0.00935 0.0114  
##  7    20   495         20.3   20.2   -0.0439  0.0108  0.0234  
##  8    25   755         25.0   24.8   -0.279   0.164   0.541   
##  9    30   442         29.6   29.4   -0.191   0.0781  0.151   
## 10    35   144         34.4   34.0   -0.415   0.310   0.195   
## 11    40     3         38.0   36.3   -1.71    2.92    0.0383
ggMiniTempHOU %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##      mse  rmse
##    <dbl> <dbl>
## 1 0.0859 0.293
ggMiniTempHOU %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using NYC/Vegas Random Forest Model on Houston Data", 
         x="Houston actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

As expected, predictions are excellent in the space covered by the training data and miss only with the very hottest observations never seen in training

The model using only NYC and Las Vegas is applied to Los Angeles, with accuracy explored by temperature:

ggMiniTempLA <- tmpPred_v3_df %>% 
    select(src, temperature_2m, pred) %>%
    filter(src=="LA") %>%
    mutate(err=pred-temperature_2m, 
           err2=err**2, 
           rnd5=round(temperature_2m/5)*5
    ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean)) %>%
    mutate(pcterr2=n*err2/sum(n*err2))
ggMiniTempLA
## # A tibble: 9 × 7
##    rnd5     n temperature_2m  pred      err    err2 pcterr2
##   <dbl> <dbl>          <dbl> <dbl>    <dbl>   <dbl>   <dbl>
## 1     0    11          0.991  1.05  0.0590  0.0195  0.00620
## 2     5   127          5.89   5.87 -0.0172  0.0127  0.0467 
## 3    10   617         10.2   10.3   0.0386  0.0206  0.368  
## 4    15   783         15.0   15.0  -0.0121  0.0107  0.241  
## 5    20   578         19.7   19.7  -0.0220  0.00852 0.142  
## 6    25   309         24.9   24.9  -0.00717 0.00572 0.0511 
## 7    30   199         29.7   29.7  -0.0382  0.00684 0.0394 
## 8    35    48         34.6   34.5  -0.0932  0.0224  0.0311 
## 9    40     5         39.6   39.2  -0.457   0.512   0.0740
ggMiniTempLA %>% 
    summarize(mse=sum(n*err2)/sum(n)) %>% 
    mutate(rmse=sqrt(mse))
## # A tibble: 1 × 2
##      mse  rmse
##    <dbl> <dbl>
## 1 0.0129 0.114
ggMiniTempLA %>% 
    select(rnd5, temperature_2m, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "temperature_2m"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Temperature Using NYC/Vegas Random Forest Model on LA Data", 
         x="Los Angeles actual temperature (rounded to nearest 5)", 
         y="Average temperature for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

As expected, predictions are excellent since the entire LA space is covered by the training data

An approximate formula for relative humidity is assessed for resonance with the data:

# Approximate formula for relative humidity
# Source https://www.omnicalculator.com/physics/relative-humidity
calcRH <- function(t, d, c1=17.63, c2=243) {
    100 * exp((c1*d)/(c2+d)) / exp((c1*t)/(c2+t))
}

# Applied to sample data
dfTestTemp_v3 %>%
    select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m) %>%
    mutate(crh=calcRH(t, d)) %>%
    ggplot(aes(x=rh, y=crh)) + 
    geom_point(aes(color=src)) + 
    facet_wrap(~src) + 
    geom_smooth(method="lm") + 
    geom_abline(intercept=0, slope=1, lty=2) + 
    labs(x="Reported relative humidity", 
         y="Formula relative humidity", 
         title="Relative humidity by formula from temperature and dewpoint vs. reported in raw data") + 
    scale_color_discrete(NULL)
## `geom_smooth()` using formula = 'y ~ x'

The formula is an exact match to the reported data, allowing the random forest to find the correct third value when given two of T, D, RH, provided that the training space also includes that combination

Example training data is created for all temperatures and dew points between -30 and 50 (rounded to the nearest 1), with RH calculated based on formula:

# Sample dataset
rhTrain <- expand.grid(t=seq(-30, 50, by=1), d=seq(-30, 50, by=1)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(rh=calcRH(t, d))
rhTrain
## # A tibble: 3,321 × 3
##        t     d    rh
##    <dbl> <dbl> <dbl>
##  1   -30   -30 100  
##  2   -29   -30  91.0
##  3   -28   -30  82.9
##  4   -27   -30  75.6
##  5   -26   -30  69.0
##  6   -25   -30  63.0
##  7   -24   -30  57.6
##  8   -23   -30  52.7
##  9   -22   -30  48.3
## 10   -21   -30  44.2
## # ℹ 3,311 more rows
# Training and testing (mtry=1)
rhOut <- rhTrain %>%
    bind_rows(.,.,.,.,.,.,.,.,.,.) %>% 
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("rh", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 98.741% (RMSE 1.17 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOut <- rhOut$tstPred
rhOut
## # A tibble: 182,635 × 5
##    src       t     d    rh  pred
##    <chr> <dbl> <dbl> <int> <dbl>
##  1 NYC    -1    -1.6    96  1.58
##  2 NYC    -0.8  -1.2    97  1.21
##  3 NYC    -0.7  -1.1    97  1.21
##  4 NYC    -0.6  -1      97  1.21
##  5 NYC     4.8   0.4    73  4.54
##  6 NYC     1.7  -0.4    86  3.84
##  7 NYC    -1.8  -6.2    72 -1.91
##  8 NYC    -2    -9.9    55 -1.50
##  9 NYC    -3.7 -13.1    48 -3.47
## 10 NYC    -8.7 -17.4    49 -7.59
## # ℹ 182,625 more rows
# Errors by city
rhOut %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2      mu     n e2Base  rmse    r2
##   <chr>   <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 1.60  -0.462  36557  125.  1.26  0.987
## 2 Houston 1.95  -0.369  36998   60.4 1.40  0.968
## 3 LA      1.22  -0.322  36972   51.9 1.11  0.976
## 4 NYC     1.63  -0.432  35474  102.  1.28  0.984
## 5 Vegas   0.398  0.0241 36634  110.  0.631 0.996
# Errors by RH
rhOut %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5    e2      mu     n e2Base  rmse    r2     e2pct
##    <dbl> <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>     <dbl>
##  1     0 6.57  -2.40       3   74.4 2.56  0.912 0.0000794
##  2     5 1.06  -0.0228  2151   46.2 1.03  0.977 0.00915  
##  3    10 0.462  0.122   6179   61.0 0.680 0.992 0.0115   
##  4    15 0.356  0.236   6865   64.8 0.596 0.995 0.00984  
##  5    20 0.243  0.113   6235   67.6 0.493 0.996 0.00610  
##  6    25 0.190 -0.0796  5763   76.5 0.436 0.998 0.00441  
##  7    30 0.193  0.0212  5964   92.0 0.439 0.998 0.00462  
##  8    35 0.205  0.116   6306  105.  0.453 0.998 0.00521  
##  9    40 0.207  0.146   7230  112.  0.455 0.998 0.00603  
## 10    45 0.192  0.0265  8165  116.  0.438 0.998 0.00632  
## 11    50 0.233 -0.149   9269  113.  0.483 0.998 0.00870  
## 12    55 0.248 -0.0917  9997  114.  0.498 0.998 0.00996  
## 13    60 0.263 -0.0551 10919  112.  0.512 0.998 0.0115   
## 14    65 0.334 -0.109  11278  115.  0.578 0.997 0.0152   
## 15    70 0.454 -0.305  12057  111.  0.674 0.996 0.0220   
## 16    75 0.464 -0.303  12812  108.  0.681 0.996 0.0239   
## 17    80 0.746 -0.536  13248  102.  0.864 0.993 0.0398   
## 18    85 3.09  -1.13   13982   85.8 1.76  0.964 0.174    
## 19    90 6.40  -0.484  15304   69.7 2.53  0.908 0.395    
## 20    95 3.80  -1.10   14419   52.8 1.95  0.928 0.221    
## 21   100 0.897 -0.838   4489   35.9 0.947 0.975 0.0162

Training data rounds temperature to the nearest degree and RH always rounds to the nearest percent, making temperature predictions commonly off by a fraction of a degree. The model is generally accurate, with the exception of very low relative humidities (rounding is much more impactful) and very high relative humidities (mtry=1 creates challenges since grid-based training data overweights some T/D combinations).

The example training data is modified to be more consistent with T/D typically observed:

# Sample of T/D in cities
set.seed(24072114)
tdAll <- allCity %>%
    select(t=temperature_2m, d=dewpoint_2m) %>%
    slice(sample(1:nrow(.), round(nrow(.)/10), replace=TRUE)) %>%
    mutate(across(where(is.numeric), .fns=round)) %>%
    count(t, d)
tdAll
## # A tibble: 1,814 × 3
##        t     d     n
##    <dbl> <dbl> <int>
##  1   -30   -34     1
##  2   -29   -34     1
##  3   -26   -32     1
##  4   -26   -30     1
##  5   -25   -29     1
##  6   -24   -28     2
##  7   -24   -27     1
##  8   -22   -28     1
##  9   -22   -26     1
## 10   -22   -25     5
## # ℹ 1,804 more rows
# Examples of real-world occurence
tdAll %>%
    ggplot(aes(x=d, y=t)) + 
    geom_point(aes(size=n), alpha=0.25) + 
    labs(title="Sample (10%) of 5-city temperature and dew points")

# Training and testing (mtry=1) weighted by real-world occurence
rhOut_wtd <- rhTrain %>%
    left_join(tdAll, by=c("t", "d")) %>%
    mutate(n=ifelse(is.na(n), 5, n+5)) %>%
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("rh", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              case.weights="n",
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 98.678% (RMSE 1.2 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOut_wtd <- rhOut_wtd$tstPred
rhOut_wtd
## # A tibble: 182,635 × 5
##    src       t     d    rh  pred
##    <chr> <dbl> <dbl> <int> <dbl>
##  1 NYC    -1    -1.6    96  1.87
##  2 NYC    -0.8  -1.2    97  1.88
##  3 NYC    -0.7  -1.1    97  1.88
##  4 NYC    -0.6  -1      97  1.88
##  5 NYC     4.8   0.4    73  4.93
##  6 NYC     1.7  -0.4    86  3.19
##  7 NYC    -1.8  -6.2    72 -1.47
##  8 NYC    -2    -9.9    55 -1.69
##  9 NYC    -3.7 -13.1    48 -3.25
## 10 NYC    -8.7 -17.4    49 -7.82
## # ℹ 182,625 more rows
# Errors by city
rhOut_wtd %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2      mu     n e2Base  rmse    r2
##   <chr>   <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 1.50  -0.553  36557  125.  1.22  0.988
## 2 Houston 2.23  -0.541  36998   60.4 1.49  0.963
## 3 LA      1.40  -0.467  36972   51.9 1.18  0.973
## 4 NYC     1.69  -0.562  35474  102.  1.30  0.983
## 5 Vegas   0.331 -0.0175 36634  110.  0.575 0.997
# Errors by RH
rhOut_wtd %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5    e2       mu     n e2Base  rmse    r2     e2pct
##    <dbl> <dbl>    <dbl> <int>  <dbl> <dbl> <dbl>     <dbl>
##  1     0 5.93  -2.24        3   74.4 2.44  0.920 0.0000682
##  2     5 1.04  -0.0480   2151   46.2 1.02  0.978 0.00854  
##  3    10 0.454  0.106    6179   61.0 0.674 0.993 0.0107   
##  4    15 0.301  0.195    6865   64.8 0.548 0.995 0.00791  
##  5    20 0.194  0.0202   6235   67.6 0.440 0.997 0.00463  
##  6    25 0.168 -0.0755   5763   76.5 0.410 0.998 0.00371  
##  7    30 0.161 -0.0931   5964   92.0 0.401 0.998 0.00368  
##  8    35 0.140 -0.00134  6306  105.  0.375 0.999 0.00339  
##  9    40 0.143  0.0280   7230  112.  0.378 0.999 0.00396  
## 10    45 0.140 -0.0439   8165  116.  0.374 0.999 0.00438  
## 11    50 0.158 -0.141    9269  113.  0.397 0.999 0.00561  
## 12    55 0.167 -0.109    9997  114.  0.409 0.999 0.00641  
## 13    60 0.190 -0.152   10919  112.  0.436 0.998 0.00796  
## 14    65 0.246 -0.161   11278  115.  0.496 0.998 0.0107   
## 15    70 0.318 -0.315   12057  111.  0.564 0.997 0.0147   
## 16    75 0.339 -0.374   12812  108.  0.582 0.997 0.0166   
## 17    80 0.555 -0.496   13248  102.  0.745 0.995 0.0282   
## 18    85 1.34  -0.739   13982   85.8 1.16  0.984 0.0721   
## 19    90 5.06  -0.731   15304   69.7 2.25  0.927 0.297    
## 20    95 7.28  -1.84    14419   52.8 2.70  0.862 0.402    
## 21   100 5.09  -2.18     4489   35.9 2.26  0.858 0.0876

The weighted training data performs slightly better for data points with high density, at the offset of somewhat worse performance for less commonly observed relative humidities

Example training data is expanded all temperatures and dew points between -50 and 50 (rounded to the nearest 1), with RH calculated based on formula:

# Sample dataset
rhTrain_ex <- expand.grid(t=seq(-50, 50, by=1), d=seq(-50, 50, by=1)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(rh=calcRH(t, d))
rhTrain_ex
## # A tibble: 5,151 × 3
##        t     d    rh
##    <dbl> <dbl> <dbl>
##  1   -50   -50 100  
##  2   -49   -50  89.2
##  3   -48   -50  79.6
##  4   -47   -50  71.2
##  5   -46   -50  63.7
##  6   -45   -50  57.1
##  7   -44   -50  51.2
##  8   -43   -50  46.0
##  9   -42   -50  41.3
## 10   -41   -50  37.2
## # ℹ 5,141 more rows
# Sample of T/D in cities from previous code section (frame 'tdAll')
# Training and testing (mtry=1) weighted by real-world occurence
rhOut_wtd_ex <- rhTrain_ex %>%
    left_join(tdAll, by=c("t", "d")) %>%
    mutate(n=ifelse(is.na(n), 5, n+5)) %>%
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("rh", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              case.weights="n",
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 98.789% (RMSE 1.14 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOut_wtd_ex <- rhOut_wtd_ex$tstPred
rhOut_wtd_ex
## # A tibble: 182,635 × 5
##    src       t     d    rh  pred
##    <chr> <dbl> <dbl> <int> <dbl>
##  1 NYC    -1    -1.6    96  3.16
##  2 NYC    -0.8  -1.2    97  3.18
##  3 NYC    -0.7  -1.1    97  3.18
##  4 NYC    -0.6  -1      97  3.18
##  5 NYC     4.8   0.4    73  4.78
##  6 NYC     1.7  -0.4    86  2.60
##  7 NYC    -1.8  -6.2    72 -1.38
##  8 NYC    -2    -9.9    55 -1.57
##  9 NYC    -3.7 -13.1    48 -3.27
## 10 NYC    -8.7 -17.4    49 -7.45
## # ℹ 182,625 more rows
# Errors by city
rhOut_wtd_ex %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2      mu     n e2Base  rmse    r2
##   <chr>   <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 1.32  -0.597  36557  125.  1.15  0.989
## 2 Houston 2.28  -0.665  36998   60.4 1.51  0.962
## 3 LA      1.10  -0.399  36972   51.9 1.05  0.979
## 4 NYC     1.53  -0.606  35474  102.  1.24  0.985
## 5 Vegas   0.306 -0.0457 36634  110.  0.553 0.997
# Errors by RH
rhOut_wtd_ex %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5    e2       mu     n e2Base  rmse    r2     e2pct
##    <dbl> <dbl>    <dbl> <int>  <dbl> <dbl> <dbl>     <dbl>
##  1     0 5.76  -2.24        3   74.4 2.40  0.923 0.0000724
##  2     5 1.01   0.0847   2151   46.2 1.01  0.978 0.00911  
##  3    10 0.417  0.0328   6179   61.0 0.646 0.993 0.0108   
##  4    15 0.245 -0.0138   6865   64.8 0.495 0.996 0.00704  
##  5    20 0.184  0.0197   6235   67.6 0.429 0.997 0.00480  
##  6    25 0.171  0.117    5763   76.5 0.413 0.998 0.00412  
##  7    30 0.157  0.0106   5964   92.0 0.396 0.998 0.00392  
##  8    35 0.139 -0.0553   6306  105.  0.373 0.999 0.00366  
##  9    40 0.143 -0.0675   7230  112.  0.378 0.999 0.00433  
## 10    45 0.132 -0.00440  8165  116.  0.363 0.999 0.00450  
## 11    50 0.157 -0.137    9269  113.  0.396 0.999 0.00609  
## 12    55 0.161 -0.109    9997  114.  0.401 0.999 0.00674  
## 13    60 0.191 -0.166   10919  112.  0.436 0.998 0.00871  
## 14    65 0.261 -0.300   11278  115.  0.511 0.998 0.0123   
## 15    70 0.296 -0.302   12057  111.  0.544 0.997 0.0150   
## 16    75 0.359 -0.349   12812  108.  0.599 0.997 0.0193   
## 17    80 0.451 -0.462   13248  102.  0.672 0.996 0.0250   
## 18    85 1.02  -0.690   13982   85.8 1.01  0.988 0.0597   
## 19    90 3.03  -0.935   15304   69.7 1.74  0.956 0.194    
## 20    95 9.09  -2.20    14419   52.8 3.02  0.828 0.549    
## 21   100 2.75  -1.60     4489   35.9 1.66  0.923 0.0517
# Errors by RH (plotted)
rhOut_wtd_ex %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    select(rh5, rmse, r2) %>%
    pivot_longer(cols=-c(rh5)) %>%
    ggplot(aes(x=rh5, y=value)) + 
    geom_point(aes(color=name)) + 
    facet_wrap(~name, ncol=1, scales="free_y") + 
    labs(title="R-squared and RMSE of temperature predictions by relative humidity", 
         x="Reported relative humidity (rounded to nearest 5)", 
         y=NULL
         ) + 
    scale_color_discrete(NULL)

The expanded training data improves prediction quality at very low temperatures. Predictions continue to be less accurate at very low, and very high, relative humidities

Rounding is a meaningful challenge for some temperature predictions given training data that rounds temperature and dewpoint to the nearest 1:

# Prediction error summaries (most of the significant errors occur when RH is 90+)
rhOut_wtd_ex %>% mutate(delta=abs(pred-t)) %>% summary()
##      src                  t                d                 rh        
##  Length:182635      Min.   :-31.10   Min.   :-35.400   Min.   :  2.00  
##  Class :character   1st Qu.:  9.10   1st Qu.: -1.300   1st Qu.: 42.00  
##  Mode  :character   Median : 16.90   Median :  7.200   Median : 65.00  
##                     Mean   : 16.22   Mean   :  6.615   Mean   : 61.05  
##                     3rd Qu.: 23.90   3rd Qu.: 14.900   3rd Qu.: 83.00  
##                     Max.   : 45.80   Max.   : 27.200   Max.   :100.00  
##       pred             delta         
##  Min.   :-30.404   Min.   :0.000001  
##  1st Qu.:  9.645   1st Qu.:0.203006  
##  Median : 17.260   Median :0.441588  
##  Mean   : 16.681   Mean   :0.737171  
##  3rd Qu.: 24.339   3rd Qu.:0.866279  
##  Max.   : 45.730   Max.   :5.065160
rhOut_wtd_ex %>% mutate(delta=abs(pred-t)) %>% filter(delta>1.5) %>% summary()
##      src                  t                d                rh       
##  Length:23492       Min.   :-22.20   Min.   :-27.50   Min.   :  2.0  
##  Class :character   1st Qu.:  9.40   1st Qu.:  7.80   1st Qu.: 90.0  
##  Mode  :character   Median : 16.40   Median : 14.80   Median : 94.0  
##                     Mean   : 15.23   Mean   : 13.41   Mean   : 91.5  
##                     3rd Qu.: 21.70   3rd Qu.: 20.40   3rd Qu.: 96.0  
##                     Max.   : 45.10   Max.   : 26.80   Max.   :100.0  
##       pred            delta      
##  Min.   :-20.59   Min.   :1.500  
##  1st Qu.: 11.77   1st Qu.:1.767  
##  Median : 18.45   Median :2.263  
##  Mean   : 17.43   Mean   :2.642  
##  3rd Qu.: 23.59   3rd Qu.:3.584  
##  Max.   : 45.73   Max.   :5.065
# Sample dataset
rhTrain_hl <- expand.grid(t=seq(-25, 50, by=0.1), d=seq(-20, 20, by=10)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(rh=calcRH(t, d), rndt=round(t), rndrh=round(rh))
rhTrain_hl
## # A tibble: 2,505 × 5
##        t     d    rh  rndt rndrh
##    <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 -20     -20 100     -20   100
##  2 -19.9   -20  99.1   -20    99
##  3 -19.8   -20  98.3   -20    98
##  4 -19.7   -20  97.5   -20    97
##  5 -19.6   -20  96.6   -20    97
##  6 -19.5   -20  95.8   -20    96
##  7 -19.4   -20  95.0   -19    95
##  8 -19.3   -20  94.2   -19    94
##  9 -19.2   -20  93.4   -19    93
## 10 -19.1   -20  92.6   -19    93
## # ℹ 2,495 more rows
# Examples for rndt==d
rhTrain_hl %>%
    filter(rndt==d) %>%
    print(n=40)
## # A tibble: 30 × 5
##          t     d    rh  rndt rndrh
##      <dbl> <dbl> <dbl> <dbl> <dbl>
##  1 -20       -20 100     -20   100
##  2 -19.9     -20  99.1   -20    99
##  3 -19.8     -20  98.3   -20    98
##  4 -19.7     -20  97.5   -20    97
##  5 -19.6     -20  96.6   -20    97
##  6 -19.5     -20  95.8   -20    96
##  7 -10       -10 100     -10   100
##  8  -9.9     -10  99.2   -10    99
##  9  -9.8     -10  98.4   -10    98
## 10  -9.7     -10  97.7   -10    98
## 11  -9.6     -10  96.9   -10    97
## 12  -9.5     -10  96.1   -10    96
## 13   0         0 100       0   100
## 14   0.100     0  99.3     0    99
## 15   0.200     0  98.6     0    99
## 16   0.300     0  97.8     0    98
## 17   0.400     0  97.1     0    97
## 18   0.5       0  96.4     0    96
## 19  10        10 100      10   100
## 20  10.1      10  99.3    10    99
## 21  10.2      10  98.7    10    99
## 22  10.3      10  98.0    10    98
## 23  10.4      10  97.4    10    97
## 24  10.5      10  96.7    10    97
## 25  20        20 100      20   100
## 26  20.1      20  99.4    20    99
## 27  20.2      20  98.8    20    99
## 28  20.3      20  98.2    20    98
## 29  20.4      20  97.6    20    98
## 30  20.5      20  97.0    20    97
# Examples for rndrh==1
rhTrain_hl %>%
    filter(rndrh<=5) %>%
    group_by(d, rndrh) %>%
    summarize(maxt=max(t), meant=mean(t), mint=min(t), n=n(), .groups="drop")
## # A tibble: 10 × 6
##        d rndrh  maxt meant  mint     n
##    <dbl> <dbl> <dbl> <dbl> <dbl> <int>
##  1   -20     1  50    46.2  42.4    77
##  2   -20     2  42.3  37.7  33      94
##  3   -20     3  32.9  30.1  27.2    58
##  4   -20     4  27.1  25.1  23      42
##  5   -20     5  22.9  21.3  19.7    33
##  6   -10     2  50    49.2  48.5    16
##  7   -10     3  48.4  45.2  42      65
##  8   -10     4  41.9  39.6  37.3    47
##  9   -10     5  37.2  35.4  33.7    36
## 10     0     5  50    49.0  47.9    22

As temperature and dewpoint converge (high relative humidity), the same rounded value of temperature can occur with RH that spans as much as ~4%. Greater granularity in the training data may help address this. As relative humidity gets very low, a given dewpoint can be associated with over 5 degrees of temperature variation for the same rounded value of RH. Since the raw data has rounded RH, this may be a harder constraint, though extremely low relative humidity is uncommon so this may not be a major driver of overall RMSE

Training data is updated to include 0.2 degree granularity for temperature and dewpoint:

# Sample dataset
rhTrain_02 <- expand.grid(t=seq(-50, 50, by=0.2), d=seq(-50, 50, by=0.2)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(rh=calcRH(t, d))
rhTrain_02
## # A tibble: 125,751 × 3
##        t     d    rh
##    <dbl> <dbl> <dbl>
##  1 -50     -50 100  
##  2 -49.8   -50  97.7
##  3 -49.6   -50  95.5
##  4 -49.4   -50  93.4
##  5 -49.2   -50  91.2
##  6 -49     -50  89.2
##  7 -48.8   -50  87.2
##  8 -48.6   -50  85.2
##  9 -48.4   -50  83.3
## 10 -48.2   -50  81.5
## # ℹ 125,741 more rows
# Training and testing (mtry=1) - NOT weighted by real-world occurence
rhOut_02 <- rhTrain_02 %>%
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("rh", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 99.843% (RMSE 0.41 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOut_02 <- rhOut_02$tstPred
rhOut_02
## # A tibble: 182,635 × 5
##    src       t     d    rh   pred
##    <chr> <dbl> <dbl> <int>  <dbl>
##  1 NYC    -1    -1.6    96 -0.345
##  2 NYC    -0.8  -1.2    97 -0.405
##  3 NYC    -0.7  -1.1    97 -0.398
##  4 NYC    -0.6  -1      97 -0.311
##  5 NYC     4.8   0.4    73  4.89 
##  6 NYC     1.7  -0.4    86  1.73 
##  7 NYC    -1.8  -6.2    72 -1.60 
##  8 NYC    -2    -9.9    55 -2.07 
##  9 NYC    -3.7 -13.1    48 -3.79 
## 10 NYC    -8.7 -17.4    49 -8.58 
## # ℹ 182,625 more rows
# Errors by city
rhOut_02 %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2      mu     n e2Base  rmse    r2
##   <chr>   <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.120 -0.113  36557  125.  0.346 0.999
## 2 Houston 0.230 -0.155  36998   60.4 0.479 0.996
## 3 LA      0.205 -0.0963 36972   51.9 0.453 0.996
## 4 NYC     0.160 -0.123  35474  102.  0.400 0.998
## 5 Vegas   0.131  0.0466 36634  110.  0.362 0.999
# Errors by RH
rhOut_02 %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5     e2       mu     n e2Base  rmse    r2    e2pct
##    <dbl>  <dbl>    <dbl> <int>  <dbl> <dbl> <dbl>    <dbl>
##  1     0 9.13   -2.74        3   74.4 3.02  0.877 0.000885
##  2     5 0.887  -0.00572  2151   46.2 0.942 0.981 0.0616  
##  3    10 0.273   0.0711   6179   61.0 0.523 0.996 0.0546  
##  4    15 0.121   0.0351   6865   64.8 0.348 0.998 0.0268  
##  5    20 0.0737  0.0802   6235   67.6 0.272 0.999 0.0149  
##  6    25 0.0547  0.105    5763   76.5 0.234 0.999 0.0102  
##  7    30 0.0348  0.0531   5964   92.0 0.187 1.00  0.00670 
##  8    35 0.0272  0.0174   6306  105.  0.165 1.00  0.00554 
##  9    40 0.0231  0.0342   7230  112.  0.152 1.00  0.00541 
## 10    45 0.0253  0.0829   8165  116.  0.159 1.00  0.00667 
## 11    50 0.0187  0.0565   9269  113.  0.137 1.00  0.00561 
## 12    55 0.0173  0.0325   9997  114.  0.131 1.00  0.00557 
## 13    60 0.0139 -0.0159  10919  112.  0.118 1.00  0.00492 
## 14    65 0.0140  0.00561 11278  115.  0.118 1.00  0.00511 
## 15    70 0.0153  0.0111  12057  111.  0.124 1.00  0.00595 
## 16    75 0.0214 -0.0571  12812  108.  0.146 1.00  0.00887 
## 17    80 0.0259 -0.0857  13248  102.  0.161 1.00  0.0111  
## 18    85 0.0329 -0.0999  13982   85.8 0.181 1.00  0.0149  
## 19    90 0.0641 -0.196   15304   69.7 0.253 0.999 0.0317  
## 20    95 0.272  -0.374   14419   52.8 0.522 0.995 0.127   
## 21   100 4.04   -1.87     4489   35.9 2.01  0.888 0.586

The model performs very well, with the exception of some remaining RMSE mainly for very high RH. Allowing both predictors (RH, D) to be used at the same time is forced using mtry=2:

rhOut_02_mt2 <- rhTrain_02 %>%
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("rh", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=2, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
    )
## Growing trees.. Progress: 96%. Estimated remaining time: 1 seconds.

## 
## R-squared of test data is: 99.962% (RMSE 0.2 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOut_02_mt2 <- rhOut_02_mt2$tstPred
rhOut_02_mt2
## # A tibble: 182,635 × 5
##    src       t     d    rh   pred
##    <chr> <dbl> <dbl> <int>  <dbl>
##  1 NYC    -1    -1.6    96 -0.996
##  2 NYC    -0.8  -1.2    97 -0.820
##  3 NYC    -0.7  -1.1    97 -0.815
##  4 NYC    -0.6  -1      97 -0.625
##  5 NYC     4.8   0.4    73  4.80 
##  6 NYC     1.7  -0.4    86  1.60 
##  7 NYC    -1.8  -6.2    72 -1.80 
##  8 NYC    -2    -9.9    55 -2.20 
##  9 NYC    -3.7 -13.1    48 -3.79 
## 10 NYC    -8.7 -17.4    49 -8.58 
## # ℹ 182,625 more rows
# Errors by city
rhOut_02_mt2 %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src         e2     mu     n e2Base  rmse    r2
##   <chr>    <dbl>  <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.0133 0.0479 36557  125.  0.116 1.00 
## 2 Houston 0.0139 0.0489 36998   60.4 0.118 1.00 
## 3 LA      0.0353 0.0530 36972   51.9 0.188 0.999
## 4 NYC     0.0134 0.0510 35474  102.  0.116 1.00 
## 5 Vegas   0.126  0.0675 36634  110.  0.355 0.999
# Errors by RH
rhOut_02_mt2 %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5      e2      mu     n e2Base   rmse    r2   e2pct
##    <dbl>   <dbl>   <dbl> <int>  <dbl>  <dbl> <dbl>   <dbl>
##  1     0 9.37    -2.76       3   74.4 3.06   0.874 0.00379
##  2     5 0.891   -0.0136  2151   46.2 0.944  0.981 0.259  
##  3    10 0.268    0.0792  6179   61.0 0.518  0.996 0.224  
##  4    15 0.121    0.0835  6865   64.8 0.348  0.998 0.112  
##  5    20 0.0688   0.0788  6235   67.6 0.262  0.999 0.0579 
##  6    25 0.0456   0.0697  5763   76.5 0.214  0.999 0.0355 
##  7    30 0.0334   0.0639  5964   92.0 0.183  1.00  0.0268 
##  8    35 0.0256   0.0624  6306  105.  0.160  1.00  0.0218 
##  9    40 0.0216   0.0598  7230  112.  0.147  1.00  0.0210 
## 10    45 0.0187   0.0585  8165  116.  0.137  1.00  0.0205 
## 11    50 0.0166   0.0552  9269  113.  0.129  1.00  0.0207 
## 12    55 0.0150   0.0559  9997  114.  0.123  1.00  0.0203 
## 13    60 0.0139   0.0526 10919  112.  0.118  1.00  0.0205 
## 14    65 0.0128   0.0511 11278  115.  0.113  1.00  0.0195 
## 15    70 0.0126   0.0527 12057  111.  0.112  1.00  0.0206 
## 16    75 0.0123   0.0488 12812  108.  0.111  1.00  0.0212 
## 17    80 0.0110   0.0431 13248  102.  0.105  1.00  0.0197 
## 18    85 0.0122   0.0495 13982   85.8 0.110  1.00  0.0229 
## 19    90 0.0110   0.0408 15304   69.7 0.105  1.00  0.0227 
## 20    95 0.0130   0.0611 14419   52.8 0.114  1.00  0.0252 
## 21   100 0.00787 -0.0108  4489   35.9 0.0887 1.00  0.00476

The model performs significantly better for very high RH, with the only meaningful errors at low RH where the impact of rounding (raw data RH is reported to the nearest percent) has the greatest impact

The process is run to predict RH based on temperature and dewpoint, starting with mtry=1:

predRH_02_mt1 <- rhTrain_02 %>%
    runFullRF(dfTrain=., 
              yVar=c("rh"), 
              xVars=c("t", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
    )

## 
## R-squared of test data is: 99.917% (RMSE 0.75 vs. 26.1 null)
## `geom_smooth()` using formula = 'y ~ x'

predRH_02_mt1 <- predRH_02_mt1$tstPred
predRH_02_mt1
## # A tibble: 182,635 × 5
##    src       t     d    rh  pred
##    <chr> <dbl> <dbl> <int> <dbl>
##  1 NYC    -1    -1.6    96  93.8
##  2 NYC    -0.8  -1.2    97  95.2
##  3 NYC    -0.7  -1.1    97  95.2
##  4 NYC    -0.6  -1      97  94.7
##  5 NYC     4.8   0.4    73  72.9
##  6 NYC     1.7  -0.4    86  85.9
##  7 NYC    -1.8  -6.2    72  71.8
##  8 NYC    -2    -9.9    55  54.4
##  9 NYC    -3.7 -13.1    48  48.1
## 10 NYC    -8.7 -17.4    49  49.6
## # ℹ 182,625 more rows
# Errors by city
predRH_02_mt1 %>%
    group_by(src) %>%
    summarize(e2=mean((rh-pred)**2), mu=mean(rh-pred), n=n(), e2Base=mean((rh-mean(rh))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2     mu     n e2Base  rmse    r2
##   <chr>   <dbl>  <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.657 0.404  36557   240. 0.811 0.997
## 2 Houston 0.702 0.470  36998   341. 0.838 0.998
## 3 LA      0.652 0.323  36972   665. 0.807 0.999
## 4 NYC     0.672 0.409  35474   321. 0.820 0.998
## 5 Vegas   0.161 0.0693 36634   376. 0.402 1.00
# Errors by RH
predRH_02_mt1 %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((rh-pred)**2), mu=mean(rh-pred), n=n(), e2Base=mean((rh-mean(rh))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5     e2       mu     n e2Base  rmse        r2      e2pct
##    <dbl>  <dbl>    <dbl> <int>  <dbl> <dbl>     <dbl>      <dbl>
##  1     0 0.208  -0.429       3  0     0.456 -Inf      0.00000600
##  2     5 0.0972 -0.0812   2151  1.27  0.312    0.924  0.00201   
##  3    10 0.0957 -0.00871  6179  1.94  0.309    0.951  0.00569   
##  4    15 0.107   0.0250   6865  2.00  0.327    0.947  0.00705   
##  5    20 0.109   0.0178   6235  2.01  0.330    0.946  0.00653   
##  6    25 0.115   0.0279   5763  1.99  0.340    0.942  0.00641   
##  7    30 0.135   0.0493   5964  2.05  0.367    0.934  0.00774   
##  8    35 0.150   0.0690   6306  2.00  0.387    0.925  0.00910   
##  9    40 0.158   0.0293   7230  1.98  0.398    0.920  0.0110    
## 10    45 0.160   0.0107   8165  1.99  0.400    0.919  0.0126    
## 11    50 0.179   0.0272   9269  2.00  0.423    0.910  0.0160    
## 12    55 0.202   0.0662   9997  2.01  0.450    0.899  0.0195    
## 13    60 0.235   0.136   10919  2.01  0.485    0.883  0.0247    
## 14    65 0.279   0.180   11278  2.01  0.528    0.861  0.0303    
## 15    70 0.294   0.170   12057  1.99  0.542    0.852  0.0341    
## 16    75 0.317   0.222   12812  2.03  0.563    0.844  0.0391    
## 17    80 0.406   0.330   13248  1.97  0.637    0.794  0.0518    
## 18    85 0.538   0.470   13982  2.00  0.733    0.732  0.0724    
## 19    90 0.834   0.727   15304  1.97  0.913    0.578  0.123     
## 20    95 1.84    1.23    14419  1.93  1.36     0.0451 0.256     
## 21   100 6.14    2.40     4489  0.554 2.48   -10.1    0.265

The model is inaccurate at high relative humidities but otherwise predicts accurately RH consistent with the known formula

The process is updated to predict RH based on temperature and dewpoint with mtry=2:

predRH_02_mt2 <- rhTrain_02 %>%
    runFullRF(dfTrain=., 
              yVar=c("rh"), 
              xVars=c("t", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=2, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, rh=relativehumidity_2m), 
              rndTo=1, 
              returnData=TRUE
    )

## 
## R-squared of test data is: 99.97% (RMSE 0.45 vs. 26.1 null)
## `geom_smooth()` using formula = 'y ~ x'

predRH_02_mt2 <- predRH_02_mt2$tstPred
predRH_02_mt2
## # A tibble: 182,635 × 5
##    src       t     d    rh  pred
##    <chr> <dbl> <dbl> <int> <dbl>
##  1 NYC    -1    -1.6    96  95.7
##  2 NYC    -0.8  -1.2    97  97.0
##  3 NYC    -0.7  -1.1    97  97.0
##  4 NYC    -0.6  -1      97  97.1
##  5 NYC     4.8   0.4    73  73.3
##  6 NYC     1.7  -0.4    86  86.5
##  7 NYC    -1.8  -6.2    72  71.9
##  8 NYC    -2    -9.9    55  54.4
##  9 NYC    -3.7 -13.1    48  48.1
## 10 NYC    -8.7 -17.4    49  49.8
## # ℹ 182,625 more rows
# Errors by city
predRH_02_mt2 %>%
    group_by(src) %>%
    summarize(e2=mean((rh-pred)**2), mu=mean(rh-pred), n=n(), e2Base=mean((rh-mean(rh))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src        e2     mu     n e2Base  rmse    r2
##   <chr>   <dbl>  <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.255 0.0224 36557   240. 0.505 0.999
## 2 Houston 0.221 0.0247 36998   341. 0.470 0.999
## 3 LA      0.197 0.0364 36972   665. 0.444 1.00 
## 4 NYC     0.229 0.0228 35474   321. 0.478 0.999
## 5 Vegas   0.117 0.0269 36634   376. 0.342 1.00
# Errors by RH
predRH_02_mt2 %>%
    mutate(rh5=round(rh/5)*5) %>%
    group_by(rh5) %>%
    summarize(e2=mean((rh-pred)**2), mu=mean(rh-pred), n=n(), e2Base=mean((rh-mean(rh))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=25)
## # A tibble: 21 × 8
##      rh5     e2       mu     n e2Base  rmse       r2     e2pct
##    <dbl>  <dbl>    <dbl> <int>  <dbl> <dbl>    <dbl>     <dbl>
##  1     0 0.145  -0.344       3  0     0.381 -Inf     0.0000117
##  2     5 0.0834 -0.0197   2151  1.27  0.289    0.935 0.00482  
##  3    10 0.0863  0.0137   6179  1.94  0.294    0.956 0.0143   
##  4    15 0.0904  0.0286   6865  2.00  0.301    0.955 0.0167   
##  5    20 0.0961  0.0328   6235  2.01  0.310    0.952 0.0161   
##  6    25 0.100   0.0269   5763  1.99  0.317    0.950 0.0155   
##  7    30 0.110   0.0271   5964  2.05  0.331    0.947 0.0176   
##  8    35 0.115   0.0245   6306  2.00  0.340    0.942 0.0196   
##  9    40 0.128   0.0227   7230  1.98  0.358    0.935 0.0250   
## 10    45 0.138   0.0213   8165  1.99  0.372    0.930 0.0304   
## 11    50 0.150   0.0185   9269  2.00  0.388    0.925 0.0374   
## 12    55 0.166   0.0229   9997  2.01  0.407    0.918 0.0445   
## 13    60 0.182   0.0204  10919  2.01  0.427    0.909 0.0534   
## 14    65 0.198   0.0199  11278  2.01  0.445    0.902 0.0600   
## 15    70 0.223   0.00685 12057  1.99  0.472    0.888 0.0721   
## 16    75 0.239   0.00575 12812  2.03  0.489    0.882 0.0823   
## 17    80 0.267   0.0121  13248  1.97  0.516    0.865 0.0950   
## 18    85 0.288   0.00731 13982  2.00  0.537    0.856 0.108    
## 19    90 0.295   0.0104  15304  1.97  0.543    0.850 0.121    
## 20    95 0.301   0.0299  14419  1.93  0.549    0.844 0.117    
## 21   100 0.403   0.393    4489  0.554 0.634    0.273 0.0486

The model is now accurate even at high relative humidities

An approximate formula for vapor pressure deficit is assessed for resonance with the data:

# Approximate formula for vapor pressure deficit
# Source https://pulsegrow.com/blogs/learn/vpd
calcVPD <- function(t, d, c1=610.78, c2=17.2694, c3=237.3) {
    # SVP (saturation vapor pressure) = 610.78 * exp(T * 17.2694 / (T + 237.3))
    # VPD = (1 - RH/100) * SVP
    # Formula produces VPD in Pa, divide by 1000 to convert to kPa
    (1 - calcRH(t, d)/100) * c1 * exp(t * c2 / (t + c3)) / 1000
}

# Applied to sample data
dfTestTemp_v3 %>%
    select(src, t=temperature_2m, d=dewpoint_2m, v=vapor_pressure_deficit) %>%
    mutate(cvpd=calcVPD(t, d)) %>%
    ggplot(aes(x=v, y=cvpd)) + 
    geom_point(aes(color=src)) + 
    facet_wrap(~src) + 
    geom_smooth(method="lm") + 
    geom_abline(intercept=0, slope=1, lty=2) + 
    labs(x="Reported vapor pressure deficit (kPa)", 
         y="Formula vapor pressure deficit (kPa)", 
         title="Vapor pressure deficit by formula from temperature and dewpoint vs. reported in raw data") + 
    scale_color_discrete(NULL)
## `geom_smooth()` using formula = 'y ~ x'

The formula is a strong match to the reported data, which should allow the random forest to find the correct third value when given two of T, D, VPD (provided that training space also includes that combination)

Example training data is created for all temperatures and dew points between -50 and 50 (rounded to the nearest 1), with VPD calculated based on formula:

# Sample dataset
rhTrainVPD <- expand.grid(t=seq(-50, 50, by=1), d=seq(-50, 50, by=1)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(vpd=calcVPD(t, d))
rhTrainVPD
## # A tibble: 5,151 × 3
##        t     d      vpd
##    <dbl> <dbl>    <dbl>
##  1   -50   -50 0       
##  2   -49   -50 0.000738
##  3   -48   -50 0.00156 
##  4   -47   -50 0.00247 
##  5   -46   -50 0.00348 
##  6   -45   -50 0.00461 
##  7   -44   -50 0.00585 
##  8   -43   -50 0.00722 
##  9   -42   -50 0.00874 
## 10   -41   -50 0.0104  
## # ℹ 5,141 more rows
# Training and testing (mtry=1)
rhOutVPD <- rhTrainVPD %>%
    bind_rows(.,.,.,.,.,.,.,.,.,.) %>% 
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("vpd", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=1, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, vpd=vapor_pressure_deficit), 
              rndTo=1, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 99.667% (RMSE 0.6 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOutVPD <- rhOutVPD$tstPred
rhOutVPD
## # A tibble: 182,635 × 5
##    src       t     d   vpd  pred
##    <chr> <dbl> <dbl> <dbl> <dbl>
##  1 NYC    -1    -1.6  0.02 -2.30
##  2 NYC    -0.8  -1.2  0.02 -1.54
##  3 NYC    -0.7  -1.1  0.02 -1.54
##  4 NYC    -0.6  -1    0.02 -1.54
##  5 NYC     4.8   0.4  0.23  4.53
##  6 NYC     1.7  -0.4  0.1   2.81
##  7 NYC    -1.8  -6.2  0.15 -1.17
##  8 NYC    -2    -9.9  0.24 -1.74
##  9 NYC    -3.7 -13.1  0.24 -3.20
## 10 NYC    -8.7 -17.4  0.16 -8.20
## # ℹ 182,625 more rows
# Errors by city
rhOutVPD %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src         e2      mu     n e2Base  rmse    r2
##   <chr>    <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.291  -0.120  36557  125.  0.539 0.998
## 2 Houston 0.720   0.161  36998   60.4 0.849 0.988
## 3 LA      0.354   0.0313 36972   51.9 0.595 0.993
## 4 NYC     0.362  -0.0388 35474  102.  0.601 0.996
## 5 Vegas   0.0710 -0.0715 36634  110.  0.267 0.999
# Errors by VPD
rhOutVPD %>%
    mutate(vpd_rnd=ifelse(vpd<0.4, round(vpd*20)/20, ifelse(vpd<2, round(vpd*5)/5, round(vpd/1)*1))) %>%
    group_by(vpd_rnd) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=30)
## # A tibble: 24 × 8
##    vpd_rnd     e2       mu     n  e2Base  rmse    r2     e2pct
##      <dbl>  <dbl>    <dbl> <int>   <dbl> <dbl> <dbl>     <dbl>
##  1    0    2.29    0.746    3081  51.6   1.51  0.956 0.107    
##  2    0.05 2.41    0.791   10402 105.    1.55  0.977 0.381    
##  3    0.1  1.28    0.0988  12935  94.8   1.13  0.986 0.253    
##  4    0.15 0.371  -0.0862  11789  89.5   0.609 0.996 0.0665   
##  5    0.2  0.190  -0.153   10651  83.5   0.436 0.998 0.0308   
##  6    0.25 0.122  -0.162    9233  74.7   0.349 0.998 0.0171   
##  7    0.3  0.114  -0.107    8018  66.5   0.338 0.998 0.0139   
##  8    0.35 0.110  -0.110    6911  59.1   0.331 0.998 0.0115   
##  9    0.4  0.0856 -0.0950  15064  50.3   0.293 0.998 0.0196   
## 10    0.6  0.0778 -0.0188  16435  41.9   0.279 0.998 0.0194   
## 11    0.8  0.0630  0.00694 13819  36.6   0.251 0.998 0.0132   
## 12    1    0.134  -0.251    9892  31.8   0.366 0.996 0.0201   
## 13    1.2  0.0941 -0.217    8747  28.5   0.307 0.997 0.0125   
## 14    1.4  0.0533 -0.119    6520  24.7   0.231 0.998 0.00528  
## 15    1.6  0.0420 -0.0535   5911  21.4   0.205 0.998 0.00378  
## 16    1.8  0.0542  0.0862   4359  18.9   0.233 0.997 0.00359  
## 17    2    0.0723  0.0217  10158  14.5   0.269 0.995 0.0112   
## 18    3    0.0431 -0.0900   9263   9.29  0.207 0.995 0.00606  
## 19    4    0.0370 -0.0382   4687   4.41  0.192 0.992 0.00264  
## 20    5    0.0300  0.0323   2502   2.02  0.173 0.985 0.00114  
## 21    6    0.0239  0.0171   1415   1.23  0.155 0.981 0.000514 
## 22    7    0.0427  0.137     605   0.766 0.207 0.944 0.000393 
## 23    8    0.0517  0.176     205   0.547 0.227 0.906 0.000161 
## 24    9    0.0975  0.266      33   0.288 0.312 0.661 0.0000489

Training data rounds temperature to the nearest degree, making temperature predictions commonly off by a fraction of a degree. The model is generally accurate, with the exception of very low/high vapor pressure deficits.

The model is updated to use mtry=2:

# Training and testing (mtry=2)
rhOutVPD_mt2 <- rhTrainVPD %>%
    bind_rows(.,.,.,.,.,.,.,.,.,.) %>% 
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("vpd", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=2, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, vpd=vapor_pressure_deficit), 
              rndTo=2, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 99.931% (RMSE 0.27 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOutVPD_mt2 <- rhOutVPD_mt2$tstPred
rhOutVPD_mt2
## # A tibble: 182,635 × 5
##    src       t     d   vpd  pred
##    <chr> <dbl> <dbl> <dbl> <dbl>
##  1 NYC    -1    -1.6  0.02 -2.06
##  2 NYC    -0.8  -1.2  0.02 -1   
##  3 NYC    -0.7  -1.1  0.02 -1   
##  4 NYC    -0.6  -1    0.02 -1   
##  5 NYC     4.8   0.4  0.23  4.54
##  6 NYC     1.7  -0.4  0.1   2.44
##  7 NYC    -1.8  -6.2  0.15 -1.54
##  8 NYC    -2    -9.9  0.24 -2.19
##  9 NYC    -3.7 -13.1  0.24 -3.82
## 10 NYC    -8.7 -17.4  0.16 -8.58
## # ℹ 182,625 more rows
# Errors by city
rhOutVPD_mt2 %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src         e2      mu     n e2Base  rmse    r2
##   <chr>    <dbl>   <dbl> <int>  <dbl> <dbl> <dbl>
## 1 Chicago 0.0807 0.0556  36557  125.  0.284 0.999
## 2 Houston 0.0930 0.0725  36998   60.4 0.305 0.998
## 3 LA      0.0664 0.0503  36972   51.9 0.258 0.999
## 4 NYC     0.0804 0.0616  35474  102.  0.284 0.999
## 5 Vegas   0.0527 0.00782 36634  110.  0.230 1.00
# Errors by VPD
rhOutVPD_mt2 %>%
    mutate(vpd_rnd=ifelse(vpd<0.4, round(vpd*20)/20, ifelse(vpd<2, round(vpd*5)/5, round(vpd/1)*1))) %>%
    group_by(vpd_rnd) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=30)
## # A tibble: 24 × 8
##    vpd_rnd     e2         mu     n  e2Base  rmse    r2    e2pct
##      <dbl>  <dbl>      <dbl> <int>   <dbl> <dbl> <dbl>    <dbl>
##  1    0    0.135   0.189      3081  51.6   0.368 0.997 0.0306  
##  2    0.05 0.176   0.211     10402 105.    0.420 0.998 0.134   
##  3    0.1  0.127   0.0873    12935  94.8   0.356 0.999 0.120   
##  4    0.15 0.114   0.0702    11789  89.5   0.337 0.999 0.0985  
##  5    0.2  0.0873  0.0103    10651  83.5   0.295 0.999 0.0682  
##  6    0.25 0.0769  0.0377     9233  74.7   0.277 0.999 0.0521  
##  7    0.3  0.0769  0.0509     8018  66.5   0.277 0.999 0.0452  
##  8    0.35 0.0741  0.0363     6911  59.1   0.272 0.999 0.0376  
##  9    0.4  0.0625  0.0319    15064  50.3   0.250 0.999 0.0690  
## 10    0.6  0.0525  0.0446    16435  41.9   0.229 0.999 0.0634  
## 11    0.8  0.0474  0.0339    13819  36.6   0.218 0.999 0.0480  
## 12    1    0.0445  0.0357     9892  31.8   0.211 0.999 0.0323  
## 13    1.2  0.0379  0.0244     8747  28.5   0.195 0.999 0.0243  
## 14    1.4  0.0341  0.0283     6520  24.7   0.185 0.999 0.0163  
## 15    1.6  0.0351  0.0364     5911  21.4   0.187 0.998 0.0152  
## 16    1.8  0.0472  0.0317     4359  18.9   0.217 0.998 0.0151  
## 17    2    0.0426  0.0236    10158  14.5   0.206 0.997 0.0318  
## 18    3    0.0588  0.0210     9263   9.29  0.242 0.994 0.0399  
## 19    4    0.0723  0.00279    4687   4.41  0.269 0.984 0.0249  
## 20    5    0.0849 -0.0209     2502   2.02  0.291 0.958 0.0156  
## 21    6    0.0986  0.00277    1415   1.23  0.314 0.920 0.0102  
## 22    7    0.112   0.0000231   605   0.766 0.335 0.853 0.00499 
## 23    8    0.104   0.0297      205   0.547 0.323 0.810 0.00157 
## 24    9    0.233   0.170        33   0.288 0.483 0.190 0.000564

The model is more accurate, particularly for very low vapor pressure deficits

Training data is updated to include 0.2 degree granularity for temperature and dewpoint:

# Sample dataset
rhTrainVPD_02 <- expand.grid(t=seq(-50, 50, by=0.2), d=seq(-50, 50, by=0.2)) %>% 
    tibble::as_tibble() %>% 
    filter(d<=t) %>% 
    mutate(vpd=calcVPD(t, d))
rhTrainVPD_02
## # A tibble: 125,751 × 3
##        t     d      vpd
##    <dbl> <dbl>    <dbl>
##  1 -50     -50 0       
##  2 -49.8   -50 0.000141
##  3 -49.6   -50 0.000286
##  4 -49.4   -50 0.000433
##  5 -49.2   -50 0.000584
##  6 -49     -50 0.000738
##  7 -48.8   -50 0.000895
##  8 -48.6   -50 0.00106 
##  9 -48.4   -50 0.00122 
## 10 -48.2   -50 0.00139 
## # ℹ 125,741 more rows
# Training and testing (mtry=2)
rhOutVPD_02_mt2 <- rhTrainVPD_02 %>%
    bind_rows(.,.,.,.,.,.,.,.,.,.) %>% 
    runFullRF(dfTrain=., 
              yVar=c("t"), 
              xVars=c("vpd", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=2, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, vpd=vapor_pressure_deficit), 
              rndTo=2, 
              returnData=TRUE
              )
## Growing trees.. Progress: 8%. Estimated remaining time: 5 minutes, 58 seconds.
## Growing trees.. Progress: 18%. Estimated remaining time: 5 minutes, 14 seconds.
## Growing trees.. Progress: 25%. Estimated remaining time: 5 minutes, 3 seconds.
## Growing trees.. Progress: 32%. Estimated remaining time: 4 minutes, 31 seconds.
## Growing trees.. Progress: 41%. Estimated remaining time: 3 minutes, 56 seconds.
## Growing trees.. Progress: 49%. Estimated remaining time: 3 minutes, 18 seconds.
## Growing trees.. Progress: 57%. Estimated remaining time: 2 minutes, 47 seconds.
## Growing trees.. Progress: 66%. Estimated remaining time: 2 minutes, 12 seconds.
## Growing trees.. Progress: 74%. Estimated remaining time: 1 minute, 40 seconds.
## Growing trees.. Progress: 82%. Estimated remaining time: 1 minute, 11 seconds.
## Growing trees.. Progress: 91%. Estimated remaining time: 36 seconds.
## Growing trees.. Progress: 99%. Estimated remaining time: 4 seconds.

## 
## R-squared of test data is: 99.995% (RMSE 0.07 vs. 10.39 null)
## `geom_smooth()` using formula = 'y ~ x'

rhOutVPD_02_mt2 <- rhOutVPD_02_mt2$tstPred
rhOutVPD_02_mt2
## # A tibble: 182,635 × 5
##    src       t     d   vpd   pred
##    <chr> <dbl> <dbl> <dbl>  <dbl>
##  1 NYC    -1    -1.6  0.02 -1.11 
##  2 NYC    -0.8  -1.2  0.02 -0.700
##  3 NYC    -0.7  -1.1  0.02 -0.699
##  4 NYC    -0.6  -1    0.02 -0.490
##  5 NYC     4.8   0.4  0.23  4.80 
##  6 NYC     1.7  -0.4  0.1   1.70 
##  7 NYC    -1.8  -6.2  0.15 -1.80 
##  8 NYC    -2    -9.9  0.24 -2.00 
##  9 NYC    -3.7 -13.1  0.24 -3.79 
## 10 NYC    -8.7 -17.4  0.16 -8.72 
## # ℹ 182,625 more rows
# Errors by city
rhOutVPD_02_mt2 %>%
    group_by(src) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src          e2       mu     n e2Base   rmse    r2
##   <chr>     <dbl>    <dbl> <int>  <dbl>  <dbl> <dbl>
## 1 Chicago 0.00844  0.0298  36557  125.  0.0919  1.00
## 2 Houston 0.00585  0.0364  36998   60.4 0.0765  1.00
## 3 LA      0.00441  0.0264  36972   51.9 0.0664  1.00
## 4 NYC     0.00674  0.0329  35474  102.  0.0821  1.00
## 5 Vegas   0.00242 -0.00111 36634  110.  0.0492  1.00
# Errors by VPD
rhOutVPD_02_mt2 %>%
    mutate(vpd_rnd=ifelse(vpd<0.4, round(vpd*20)/20, ifelse(vpd<2, round(vpd*5)/5, round(vpd/1)*1))) %>%
    group_by(vpd_rnd) %>%
    summarize(e2=mean((t-pred)**2), mu=mean(t-pred), n=n(), e2Base=mean((t-mean(t))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=30)
## # A tibble: 24 × 8
##    vpd_rnd      e2        mu     n  e2Base   rmse    r2     e2pct
##      <dbl>   <dbl>     <dbl> <int>   <dbl>  <dbl> <dbl>     <dbl>
##  1    0    0.0157   0.0784    3081  51.6   0.125  1.00  0.0477   
##  2    0.05 0.0136   0.0436   10402 105.    0.117  1.00  0.139    
##  3    0.1  0.0103   0.0386   12935  94.8   0.101  1.00  0.131    
##  4    0.15 0.00893  0.0353   11789  89.5   0.0945 1.00  0.104    
##  5    0.2  0.00783  0.0329   10651  83.5   0.0885 1.00  0.0821   
##  6    0.25 0.00689  0.0305    9233  74.7   0.0830 1.00  0.0626   
##  7    0.3  0.00621  0.0292    8018  66.5   0.0788 1.00  0.0490   
##  8    0.35 0.00570  0.0291    6911  59.1   0.0755 1.00  0.0388   
##  9    0.4  0.00508  0.0273   15064  50.3   0.0713 1.00  0.0754   
## 10    0.6  0.00436  0.0247   16435  41.9   0.0661 1.00  0.0706   
## 11    0.8  0.00364  0.0216   13819  36.6   0.0603 1.00  0.0495   
## 12    1    0.00322  0.0186    9892  31.8   0.0568 1.00  0.0314   
## 13    1.2  0.00294  0.0173    8747  28.5   0.0542 1.00  0.0253   
## 14    1.4  0.00264  0.0169    6520  24.7   0.0514 1.00  0.0169   
## 15    1.6  0.00259  0.0159    5911  21.4   0.0509 1.00  0.0151   
## 16    1.8  0.00243  0.0149    4359  18.9   0.0493 1.00  0.0104   
## 17    2    0.00210  0.0119   10158  14.5   0.0458 1.00  0.0210   
## 18    3    0.00164  0.00576   9263   9.29  0.0405 1.00  0.0150   
## 19    4    0.00143 -0.000393  4687   4.41  0.0378 1.00  0.00658  
## 20    5    0.00163 -0.00335   2502   2.02  0.0404 0.999 0.00402  
## 21    6    0.00212 -0.0104    1415   1.23  0.0460 0.998 0.00295  
## 22    7    0.00245 -0.0137     605   0.766 0.0495 0.997 0.00146  
## 23    8    0.00236 -0.0116     205   0.547 0.0486 0.996 0.000477 
## 24    9    0.00263 -0.0169      33   0.288 0.0513 0.991 0.0000855

Predictions become extremely accurate, at the expense of long run times

The model is run to predict VPD as f(T, D):

# Training and testing (mtry=2)
predVPD_02_mt2 <- rhTrainVPD_02 %>%
    # bind_rows(.,.,.,.,.,.,.,.,.,.) %>%
    runFullRF(dfTrain=., 
              yVar=c("vpd"), 
              xVars=c("t", "d"), 
              isContVar=TRUE, 
              refXY=TRUE, 
              mtry=2, 
              dfTest=allCity %>%
                  filter(tt=="test") %>%
                  select(src, t=temperature_2m, d=dewpoint_2m, vpd=vapor_pressure_deficit), 
              rndTo=0.025, 
              returnData=TRUE
              )

## 
## R-squared of test data is: 99.991% (RMSE 0.01 vs. 1.2 null)
## `geom_smooth()` using formula = 'y ~ x'

predVPD_02_mt2 <- predVPD_02_mt2$tstPred
predVPD_02_mt2
## # A tibble: 182,635 × 5
##    src       t     d   vpd   pred
##    <chr> <dbl> <dbl> <dbl>  <dbl>
##  1 NYC    -1    -1.6  0.02 0.0247
##  2 NYC    -0.8  -1.2  0.02 0.0167
##  3 NYC    -0.7  -1.1  0.02 0.0167
##  4 NYC    -0.6  -1    0.02 0.0178
##  5 NYC     4.8   0.4  0.23 0.232 
##  6 NYC     1.7  -0.4  0.1  0.0931
##  7 NYC    -1.8  -6.2  0.15 0.151 
##  8 NYC    -2    -9.9  0.24 0.241 
##  9 NYC    -3.7 -13.1  0.24 0.239 
## 10 NYC    -8.7 -17.4  0.16 0.158 
## # ℹ 182,625 more rows
# Errors by city
predVPD_02_mt2 %>%
    group_by(src) %>%
    summarize(e2=mean((vpd-pred)**2), mu=mean(vpd-pred), n=n(), e2Base=mean((vpd-mean(vpd))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base)
## # A tibble: 5 × 7
##   src            e2      mu     n e2Base    rmse    r2
##   <chr>       <dbl>   <dbl> <int>  <dbl>   <dbl> <dbl>
## 1 Chicago 0.0000808 0.00126 36557  0.248 0.00899  1.00
## 2 Houston 0.000159  0.00166 36998  0.590 0.0126   1.00
## 3 LA      0.000113  0.00305 36972  1.07  0.0106   1.00
## 4 NYC     0.0000790 0.00119 35474  0.298 0.00889  1.00
## 5 Vegas   0.000236  0.00865 36634  2.93  0.0154   1.00
# Errors by VPD
predVPD_02_mt2 %>%
    mutate(vpd_rnd=ifelse(vpd<0.4, round(vpd*20)/20, ifelse(vpd<2, round(vpd*5)/5, round(vpd/1)*1))) %>%
    group_by(vpd_rnd) %>%
    summarize(e2=mean((vpd-pred)**2), mu=mean(vpd-pred), n=n(), e2Base=mean((vpd-mean(vpd))**2)) %>%
    mutate(rmse=sqrt(e2), r2=1-e2/e2Base, e2pct=n*e2/sum(n*e2)) %>%
    print(n=30)
## # A tibble: 24 × 8
##    vpd_rnd        e2        mu     n    e2Base    rmse     r2   e2pct
##      <dbl>     <dbl>     <dbl> <int>     <dbl>   <dbl>  <dbl>   <dbl>
##  1    0    0.0000998 -0.00744   3081 0.0000547 0.00999 -0.825 0.0126 
##  2    0.05 0.0000464 -0.000706 10402 0.000188  0.00681  0.753 0.0197 
##  3    0.1  0.0000565  0.000282 12935 0.000201  0.00751  0.719 0.0298 
##  4    0.15 0.0000639  0.000490 11789 0.000199  0.00800  0.678 0.0308 
##  5    0.2  0.0000671  0.000651 10651 0.000201  0.00819  0.666 0.0292 
##  6    0.25 0.0000692  0.000996  9233 0.000201  0.00832  0.655 0.0261 
##  7    0.3  0.0000748  0.00125   8018 0.000201  0.00865  0.627 0.0245 
##  8    0.35 0.0000798  0.00126   6911 0.000201  0.00893  0.603 0.0225 
##  9    0.4  0.0000838  0.00166  15064 0.00138   0.00915  0.939 0.0515 
## 10    0.6  0.0000914  0.00208  16435 0.00299   0.00956  0.969 0.0614 
## 11    0.8  0.000105   0.00276  13819 0.00364   0.0102   0.971 0.0592 
## 12    1    0.000115   0.00342   9892 0.00302   0.0107   0.962 0.0465 
## 13    1.2  0.000130   0.00398   8747 0.00371   0.0114   0.965 0.0464 
## 14    1.4  0.000142   0.00442   6520 0.00298   0.0119   0.952 0.0379 
## 15    1.6  0.000160   0.00482   5911 0.00368   0.0126   0.957 0.0385 
## 16    1.8  0.000182   0.00616   4359 0.00302   0.0135   0.940 0.0324 
## 17    2    0.000214   0.00708  10158 0.0309    0.0146   0.993 0.0887 
## 18    3    0.000293   0.00969   9263 0.0802    0.0171   0.996 0.111  
## 19    4    0.000431   0.0133    4687 0.0813    0.0208   0.995 0.0824 
## 20    5    0.000604   0.0166    2502 0.0808    0.0246   0.993 0.0617 
## 21    6    0.000823   0.0204    1415 0.0777    0.0287   0.989 0.0475 
## 22    7    0.00108    0.0239     605 0.0774    0.0329   0.986 0.0267 
## 23    8    0.00135    0.0274     205 0.0672    0.0368   0.980 0.0113 
## 24    9    0.00152    0.0282      33 0.0486    0.0390   0.969 0.00205

Predictions are very accurate, as expected

A model is run to predict cloud cover, at first allowing the cloud subset data (low, mid, high):

keyLabel <- "predictions based on pre-2022 training data applied to 2022 holdout dataset"
rfCloudFull <- runFullRF(dfTrain=allCity %>% filter(tt=="train", year<2022), 
                      yVar="cloudcover", 
                      xVars=c(varsTrain[!str_detect(varsTrain, "cloudcover$")]), 
                      dfTest=allCity %>% filter(tt=="test", year==2022), 
                      useLabel=keyLabel, 
                      useSub=stringr::str_to_sentence(keyLabel), 
                      isContVar=TRUE,
                      rndTo=-1L,
                      refXY=TRUE,
                      returnData=TRUE
                      )
## Growing trees.. Progress: 17%. Estimated remaining time: 2 minutes, 33 seconds.
## Growing trees.. Progress: 34%. Estimated remaining time: 1 minute, 59 seconds.
## Growing trees.. Progress: 51%. Estimated remaining time: 1 minute, 29 seconds.
## Growing trees.. Progress: 68%. Estimated remaining time: 58 seconds.
## Growing trees.. Progress: 83%. Estimated remaining time: 31 seconds.
## Growing trees.. Progress: 100%. Estimated remaining time: 0 seconds.

## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.481% (RMSE 2.61 vs. 36.27 null)
## `geom_smooth()` using formula = 'y ~ x'

The model is effective at predicting cloud cover. Of interest, variable importance is highest for ‘weathercode’, a categorical variable improperly run as an integer. The interpretation of WMO weather codes is available at https://www.nodc.noaa.gov/archive/arc0021/0002199/1.1/data/0-data/HTML/WMO-CODE/WMO4677.HTM

The weather code and cloud cover variables are explored:

# Distribution of 'cloudcover'
allCity %>% 
    select(weathercode, cloudcover) %>% 
    mutate(weathercode=factor(weathercode)) %>% 
    ggplot(aes(x=cloudcover)) + 
    geom_histogram(bins=50, aes(y=after_stat(count)/sum(after_stat(count)))) + 
    labs(title="Distribution of cloud cover", y="Proportion of total observations")

# Distribution of 'weathercode'
allCity %>% 
    select(weathercode, cloudcover) %>% 
    mutate(weathercode=factor(weathercode)) %>% 
    ggplot(aes(x=weathercode)) + 
    geom_bar(aes(y=after_stat(count)/sum(after_stat(count)))) + 
    labs(title="Distribution of weather code", y="Proportion of total observations")

# Cloud cover boxplot by weather code
allCity %>% 
    select(weathercode, cloudcover) %>% 
    mutate(weathercode=factor(weathercode)) %>% 
    ggplot(aes(x=weathercode, y=cloudcover)) + 
    geom_boxplot(fill="lightblue") + 
    labs(title="Cloud cover by weather code", y="Cloud cover")

Weather code is strongly predictive of cloud cover, with codes 00 and 01 associated with few clouds and other clouds associated with many clouds

The model is run to predict cloud cover using only weather code as a factor:

keyLabel <- "predictions based on pre-2022 training data applied to 2022 holdout dataset"
runFullRF(dfTrain=allCity %>% mutate(fct_wmo=factor(weathercode)) %>% filter(tt=="train", year<2022), 
          yVar="cloudcover", 
          xVars=c("fct_wmo"), 
          dfTest=allCity %>% mutate(fct_wmo=factor(weathercode)) %>% filter(tt=="test", year==2022), 
          useLabel=keyLabel, 
          useSub=stringr::str_to_sentence(keyLabel), 
          isContVar=TRUE,
          rndTo=-1L,
          refXY=TRUE,
          returnData=FALSE
          )

## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.458% (RMSE 9.96 vs. 36.27 null)
## `geom_smooth()` using formula = 'y ~ x'

The model drives over 90% R-squared, with RMSE falling from ~35 in the baseline to ~10 with predictions based solely on weather code

The model is run to predict cloud cover using only the three cloud cover (low, mid, high) predictors:

keyLabel <- "predictions based on pre-2022 training data applied to 2022 holdout dataset"
runFullRF(dfTrain=allCity %>% mutate(fct_wmo=factor(weathercode)) %>% filter(tt=="train", year<2022), 
          yVar="cloudcover", 
          xVars=c(varsTrain[str_detect(varsTrain, pattern="cloudcover_")]), 
          dfTest=allCity %>% mutate(fct_wmo=factor(weathercode)) %>% filter(tt=="test", year==2022), 
          useLabel=keyLabel, 
          useSub=stringr::str_to_sentence(keyLabel), 
          isContVar=TRUE,
          rndTo=-1L,
          refXY=TRUE,
          returnData=FALSE
          )
## Growing trees.. Progress: 93%. Estimated remaining time: 2 seconds.

## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.129% (RMSE 3.39 vs. 36.27 null)
## `geom_smooth()` using formula = 'y ~ x'

The model drives over 99% R-squared, with RMSE falling from ~35 in the baseline to ~3 with predictions based solely on cloud cover sub-types

All combinations of two variables are explored for predicting cloud cover on a smaller training dataset:

# Train and test data
dfTrainCloud <- allCity %>% 
    filter(tt=="train", year<2022) %>% 
    mutate(fct_src=factor(src))
dfTestCloud <- allCity %>% 
    filter(tt=="test", year==2022) %>% 
    mutate(fct_src=factor(src))

# Variables to explore
possCloudVars <- c(varsTrain[!str_detect(varsTrain, "cover$")], "month", "tod")

# Subsets to use
set.seed(24080616)
idxSmallCloud <- sample(1:nrow(dfTrainCloud), 5000, replace=FALSE)
mtxSmallCloud <- matrix(nrow=0, ncol=3)

for(idx1 in 1:(length(possCloudVars)-1)) {
    for(idx2 in (idx1+1):length(possCloudVars)) {
        r2SmallCloud <- runFullRF(dfTrain=dfTrainCloud[idxSmallCloud,], 
                                  yVar="cloudcover", 
                                  xVars=possCloudVars[c(idx1, idx2)], 
                                  dfTest=dfTestCloud, 
                                  useLabel=keyLabel, 
                                  useSub=stringr::str_to_sentence(keyLabel), 
                                  isContVar=TRUE,
                                  makePlots=FALSE,
                                  returnData=TRUE
                                  )[["rfAcc"]][["r2"]]
        mtxSmallCloud <- rbind(mtxSmallCloud, c(idx1, idx2, r2SmallCloud))
    }
}
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.345% (RMSE 36.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.025% (RMSE 30.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.405% (RMSE 36.53 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.724% (RMSE 36.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.72% (RMSE 36.94 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.649% (RMSE 35.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.495% (RMSE 31.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.401% (RMSE 32.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.944% (RMSE 35.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.722% (RMSE 21.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.433% (RMSE 26.3 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.782% (RMSE 32.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.022% (RMSE 33.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.673% (RMSE 32.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.009% (RMSE 30.78 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.063% (RMSE 34.59 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.179% (RMSE 37.02 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.091% (RMSE 36.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.492% (RMSE 37.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.869% (RMSE 37.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.03% (RMSE 36.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.382% (RMSE 33.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.079% (RMSE 10.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.003% (RMSE 32.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.298% (RMSE 36.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.628% (RMSE 36.16 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.948% (RMSE 36.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.571% (RMSE 35.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.649% (RMSE 35.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.323% (RMSE 35.85 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.287% (RMSE 36.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.867% (RMSE 35.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.672% (RMSE 36.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.325% (RMSE 37.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.705% (RMSE 36.15 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.183% (RMSE 36.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.577% (RMSE 32.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.12% (RMSE 33.22 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.115% (RMSE 36.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.732% (RMSE 36.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.539% (RMSE 35.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.049% (RMSE 31.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.706% (RMSE 31.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.775% (RMSE 35.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.152% (RMSE 21.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.784% (RMSE 26.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.941% (RMSE 31.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.59% (RMSE 35.62 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.587% (RMSE 35.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.386% (RMSE 33.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.564% (RMSE 34.69 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.489% (RMSE 37.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.003% (RMSE 37.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.142% (RMSE 37.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.268% (RMSE 37.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.09% (RMSE 37.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.762% (RMSE 36.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.533% (RMSE 9.22 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.541% (RMSE 32.94 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.541% (RMSE 37.62 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.843% (RMSE 36.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.273% (RMSE 36.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.834% (RMSE 36.61 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.293% (RMSE 35.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.787% (RMSE 36.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.527% (RMSE 36.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.007% (RMSE 36.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.155% (RMSE 36.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.982% (RMSE 37.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.157% (RMSE 35.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.055% (RMSE 35.53 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.849% (RMSE 32.88 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.019% (RMSE 32.84 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.093% (RMSE 32.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.267% (RMSE 32.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 34.348% (RMSE 29.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.912% (RMSE 29.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.237% (RMSE 31.78 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.126% (RMSE 21.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 58.464% (RMSE 23.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 38.647% (RMSE 28.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.742% (RMSE 31.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.515% (RMSE 31.72 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.541% (RMSE 30.66 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.347% (RMSE 30.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.086% (RMSE 31.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.758% (RMSE 32.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.576% (RMSE 33.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.681% (RMSE 33.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.356% (RMSE 30.92 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.242% (RMSE 31.36 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.148% (RMSE 9.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.576% (RMSE 32.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.743% (RMSE 32.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.306% (RMSE 32.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.493% (RMSE 32.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.841% (RMSE 32.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.275% (RMSE 32.79 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.518% (RMSE 32.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.731% (RMSE 32.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.197% (RMSE 32.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.85% (RMSE 32.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.915% (RMSE 32.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.717% (RMSE 31.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.374% (RMSE 31.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.137% (RMSE 32.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.88% (RMSE 37.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.174% (RMSE 36.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.033% (RMSE 31.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.253% (RMSE 32.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.317% (RMSE 34.92 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.043% (RMSE 21.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.864% (RMSE 26.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.498% (RMSE 32.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.971% (RMSE 35.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.283% (RMSE 34.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.339% (RMSE 33.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.123% (RMSE 35.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.242% (RMSE 37.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.438% (RMSE 36.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.788% (RMSE 38.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.494% (RMSE 37.96 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.133% (RMSE 37.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.069% (RMSE 35.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.105% (RMSE 9.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.421% (RMSE 32.96 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.061% (RMSE 33.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.767% (RMSE 32.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.838% (RMSE 33.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.325% (RMSE 35.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.654% (RMSE 35.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.303% (RMSE 36.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.051% (RMSE 36.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.524% (RMSE 36.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.981% (RMSE 36.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.638% (RMSE 35.79 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.424% (RMSE 34.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.443% (RMSE 35.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.391% (RMSE 37.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.779% (RMSE 35.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.118% (RMSE 31.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.88% (RMSE 31.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.895% (RMSE 35.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.925% (RMSE 21.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.383% (RMSE 26.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.334% (RMSE 31.97 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.086% (RMSE 36.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.262% (RMSE 35.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.784% (RMSE 33.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.038% (RMSE 35.16 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.721% (RMSE 37.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.346% (RMSE 37.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.729% (RMSE 37.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.502% (RMSE 38.13 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.063% (RMSE 37.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.864% (RMSE 36.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.571% (RMSE 9.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.525% (RMSE 33.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.154% (RMSE 37.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.293% (RMSE 36.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.274% (RMSE 36.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.022% (RMSE 37.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.704% (RMSE 35.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.91% (RMSE 36.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.228% (RMSE 37.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.442% (RMSE 36.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.36% (RMSE 36.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.43% (RMSE 37.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.451% (RMSE 36.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.937% (RMSE 35.92 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.668% (RMSE 35.97 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.089% (RMSE 32.02 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.995% (RMSE 32.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.168% (RMSE 35.69 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.69% (RMSE 21.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.385% (RMSE 26.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.373% (RMSE 32.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.424% (RMSE 36.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.296% (RMSE 35.67 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.94% (RMSE 34.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.467% (RMSE 35.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -11.152% (RMSE 38.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.713% (RMSE 38.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -14.065% (RMSE 38.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -14.547% (RMSE 38.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.053% (RMSE 38.05 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.948% (RMSE 36.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.214% (RMSE 10.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.965% (RMSE 33.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.381% (RMSE 37.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.005% (RMSE 36.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.805% (RMSE 36.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.579% (RMSE 36.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.617% (RMSE 35.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.664% (RMSE 36.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.029% (RMSE 36.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.446% (RMSE 36.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.712% (RMSE 36.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.39% (RMSE 37.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.515% (RMSE 35.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.163% (RMSE 36.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.917% (RMSE 30.8 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.416% (RMSE 31.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.124% (RMSE 34.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.107% (RMSE 21.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.112% (RMSE 25.88 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.623% (RMSE 31.28 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.417% (RMSE 34.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.068% (RMSE 34.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.017% (RMSE 32.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.921% (RMSE 34.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.893% (RMSE 36.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.6% (RMSE 36.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.053% (RMSE 36.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.4% (RMSE 36.53 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.362% (RMSE 36.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.914% (RMSE 34.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.537% (RMSE 9.91 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.663% (RMSE 33.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.924% (RMSE 35.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.303% (RMSE 35.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.264% (RMSE 35.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.461% (RMSE 35.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.661% (RMSE 34.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.264% (RMSE 35.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.776% (RMSE 36.95 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.148% (RMSE 36.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.658% (RMSE 34.67 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.734% (RMSE 35.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.789% (RMSE 34.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.124% (RMSE 34.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.46% (RMSE 31.94 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.459% (RMSE 32.15 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.619% (RMSE 21.27 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.35% (RMSE 25.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 38.065% (RMSE 28.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.433% (RMSE 31.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.386% (RMSE 30.91 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.549% (RMSE 30.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.782% (RMSE 30.61 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.507% (RMSE 31.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.332% (RMSE 31.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.759% (RMSE 31.88 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.63% (RMSE 31.91 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.737% (RMSE 31.88 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.723% (RMSE 31.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 84.134% (RMSE 14.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 34.033% (RMSE 29.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.895% (RMSE 31.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.897% (RMSE 31.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.309% (RMSE 30.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.299% (RMSE 30.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.568% (RMSE 30.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.024% (RMSE 30.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.336% (RMSE 31.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.682% (RMSE 30.85 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.826% (RMSE 31.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.307% (RMSE 31.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.61% (RMSE 31.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.186% (RMSE 32.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.004% (RMSE 32.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.055% (RMSE 21.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.689% (RMSE 25.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 36.182% (RMSE 28.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.527% (RMSE 31.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.393% (RMSE 31.54 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.911% (RMSE 30.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.381% (RMSE 31.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.763% (RMSE 32.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.521% (RMSE 32.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.638% (RMSE 32.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.421% (RMSE 32.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.854% (RMSE 32.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.73% (RMSE 31.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 83.655% (RMSE 14.67 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.076% (RMSE 29.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.339% (RMSE 31.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.968% (RMSE 31.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.552% (RMSE 31.3 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.185% (RMSE 31.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.044% (RMSE 31.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.558% (RMSE 31.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.583% (RMSE 31.92 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.288% (RMSE 31.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.681% (RMSE 32.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.321% (RMSE 32.18 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.595% (RMSE 32.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.418% (RMSE 32.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 61.065% (RMSE 22.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 45.299% (RMSE 26.83 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.869% (RMSE 31.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.284% (RMSE 34.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.13% (RMSE 34.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.347% (RMSE 33.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.206% (RMSE 34.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.941% (RMSE 35.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.258% (RMSE 35.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.234% (RMSE 35.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.683% (RMSE 35.78 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.479% (RMSE 35.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.972% (RMSE 34.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 81.41% (RMSE 15.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.122% (RMSE 32.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.791% (RMSE 35.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.479% (RMSE 35.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.191% (RMSE 34.95 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.026% (RMSE 34.79 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.542% (RMSE 33.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.684% (RMSE 34.28 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.454% (RMSE 34.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.867% (RMSE 34.05 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.864% (RMSE 35.75 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.12% (RMSE 35.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.164% (RMSE 35.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.547% (RMSE 35.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 90.622% (RMSE 11.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 83.417% (RMSE 14.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.438% (RMSE 21.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.548% (RMSE 21.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 67.343% (RMSE 20.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.97% (RMSE 20.85 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.19% (RMSE 21.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.564% (RMSE 21.59 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.074% (RMSE 21.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.121% (RMSE 21.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.69% (RMSE 21.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.155% (RMSE 21.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 94.832% (RMSE 8.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.076% (RMSE 21.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.095% (RMSE 21.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.205% (RMSE 21.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.067% (RMSE 21.13 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.892% (RMSE 21.18 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.219% (RMSE 21.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.911% (RMSE 21.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.505% (RMSE 21.61 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 66.299% (RMSE 21.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.549% (RMSE 21.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 64.251% (RMSE 21.69 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 65.155% (RMSE 21.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 59.366% (RMSE 23.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 55.104% (RMSE 24.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.303% (RMSE 26.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.125% (RMSE 25.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 51.838% (RMSE 25.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 50.59% (RMSE 25.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.685% (RMSE 26.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.623% (RMSE 26.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.696% (RMSE 26.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.457% (RMSE 26.54 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.215% (RMSE 26.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.184% (RMSE 25.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.707% (RMSE 9.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 56.103% (RMSE 24.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.539% (RMSE 26.02 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.733% (RMSE 25.97 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.19% (RMSE 26.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.445% (RMSE 26.3 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.81% (RMSE 25.7 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 48.552% (RMSE 26.02 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.77% (RMSE 26.22 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.663% (RMSE 26.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 46.71% (RMSE 26.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 47.704% (RMSE 26.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 49.132% (RMSE 25.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 43.548% (RMSE 27.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.286% (RMSE 31.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.167% (RMSE 30.96 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 32.937% (RMSE 29.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 26.806% (RMSE 31.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.629% (RMSE 32.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.711% (RMSE 32.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.685% (RMSE 32.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.762% (RMSE 32.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.256% (RMSE 32.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.391% (RMSE 31.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.434% (RMSE 9.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 38.405% (RMSE 28.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.373% (RMSE 31.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.909% (RMSE 31.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.304% (RMSE 31.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.248% (RMSE 31.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.466% (RMSE 30.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.576% (RMSE 31.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.972% (RMSE 31.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 25.651% (RMSE 31.28 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.506% (RMSE 31.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.609% (RMSE 32.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.744% (RMSE 31.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 23.435% (RMSE 31.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.41% (RMSE 30.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.781% (RMSE 30.18 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.292% (RMSE 30.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.442% (RMSE 35.83 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.873% (RMSE 35.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.499% (RMSE 36.36 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.628% (RMSE 36.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.846% (RMSE 35.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.638% (RMSE 34.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.649% (RMSE 9.83 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.867% (RMSE 31.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.909% (RMSE 35.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.021% (RMSE 35.35 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.405% (RMSE 35.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.317% (RMSE 35.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.253% (RMSE 34.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.287% (RMSE 34.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.205% (RMSE 35.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.046% (RMSE 34.78 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.91% (RMSE 35.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.056% (RMSE 35.72 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.067% (RMSE 34.97 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.692% (RMSE 35.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 24.54% (RMSE 31.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.399% (RMSE 30.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.159% (RMSE 35.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.355% (RMSE 35.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.497% (RMSE 35.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.164% (RMSE 35.88 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.242% (RMSE 34.75 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.724% (RMSE 34.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.197% (RMSE 10.13 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.95% (RMSE 32.05 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.511% (RMSE 35.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.329% (RMSE 34.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.628% (RMSE 34.67 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.23% (RMSE 34.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.07% (RMSE 33.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.91% (RMSE 34.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.826% (RMSE 34.83 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.052% (RMSE 34.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.663% (RMSE 35.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.974% (RMSE 35.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.146% (RMSE 34.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.85% (RMSE 34.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 30.864% (RMSE 30.16 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.903% (RMSE 33.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.401% (RMSE 33.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.875% (RMSE 33.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.997% (RMSE 34.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.873% (RMSE 33.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.83% (RMSE 32.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.199% (RMSE 10.13 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 28.233% (RMSE 30.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.879% (RMSE 33.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.239% (RMSE 33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.728% (RMSE 32.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.744% (RMSE 32.7 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 21.789% (RMSE 32.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.702% (RMSE 32.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.267% (RMSE 33.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.789% (RMSE 32.69 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.678% (RMSE 33.51 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.529% (RMSE 33.54 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.612% (RMSE 33.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.134% (RMSE 32.62 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.849% (RMSE 35.75 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.571% (RMSE 35.8 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.303% (RMSE 36.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.682% (RMSE 36.15 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.83% (RMSE 35.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 27.277% (RMSE 30.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.566% (RMSE 9.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 31.533% (RMSE 30.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.679% (RMSE 34.85 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.078% (RMSE 34.59 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.954% (RMSE 34.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.934% (RMSE 34.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.435% (RMSE 33.94 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.743% (RMSE 34.84 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.651% (RMSE 35.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.62% (RMSE 35.05 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.931% (RMSE 35.37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.24% (RMSE 35.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.461% (RMSE 34.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.719% (RMSE 35.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.302% (RMSE 38.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -13.129% (RMSE 38.58 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -11.065% (RMSE 38.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.262% (RMSE 37.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.187% (RMSE 35.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.116% (RMSE 10.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 17.046% (RMSE 33.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.946% (RMSE 37.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.093% (RMSE 37.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.901% (RMSE 36.97 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.571% (RMSE 37.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.588% (RMSE 35.62 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.58% (RMSE 36.56 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.524% (RMSE 36.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.142% (RMSE 36.48 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.405% (RMSE 36.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.484% (RMSE 37.96 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.196% (RMSE 36.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.554% (RMSE 35.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.957% (RMSE 38.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.897% (RMSE 38.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.768% (RMSE 37.66 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.398% (RMSE 35.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.298% (RMSE 10.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.977% (RMSE 33.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.85% (RMSE 37.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.655% (RMSE 37.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.251% (RMSE 37.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.012% (RMSE 36.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.459% (RMSE 35.64 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.109% (RMSE 36.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.571% (RMSE 36.92 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.514% (RMSE 36.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.889% (RMSE 36.11 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.453% (RMSE 37.78 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.545% (RMSE 35.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.973% (RMSE 35.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -12.9% (RMSE 38.54 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -10.175% (RMSE 38.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.914% (RMSE 36.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.314% (RMSE 10.06 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 12.941% (RMSE 33.85 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.181% (RMSE 37.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.793% (RMSE 37.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.034% (RMSE 37 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.377% (RMSE 37.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.798% (RMSE 36.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.484% (RMSE 37.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.776% (RMSE 36.95 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.416% (RMSE 37.59 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.544% (RMSE 36.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -11.41% (RMSE 38.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.139% (RMSE 36.3 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.384% (RMSE 36.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -11.264% (RMSE 38.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.843% (RMSE 36.61 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.323% (RMSE 10.05 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.094% (RMSE 33.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -9.62% (RMSE 37.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.249% (RMSE 37.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.593% (RMSE 37.1 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.289% (RMSE 37.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.39% (RMSE 36.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.909% (RMSE 36.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.642% (RMSE 37.28 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.192% (RMSE 37.73 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.14% (RMSE 36.66 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -11.995% (RMSE 38.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.374% (RMSE 36.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.267% (RMSE 36.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.198% (RMSE 34.76 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.121% (RMSE 10.18 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 19.226% (RMSE 32.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.165% (RMSE 37.2 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.906% (RMSE 37.15 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.08% (RMSE 37.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.404% (RMSE 36.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.468% (RMSE 35.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.044% (RMSE 36.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.911% (RMSE 36.8 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.329% (RMSE 36.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.021% (RMSE 36.27 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -7.461% (RMSE 37.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.707% (RMSE 35.96 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.878% (RMSE 35.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.91% (RMSE 9.66 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.253% (RMSE 31.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.755% (RMSE 35.95 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.21% (RMSE 35.69 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.657% (RMSE 35.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.49% (RMSE 35.45 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.381% (RMSE 34.72 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.461% (RMSE 35.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.434% (RMSE 35.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.717% (RMSE 35.22 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.947% (RMSE 35.74 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.692% (RMSE 36.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.693% (RMSE 35.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.178% (RMSE 34.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.676% (RMSE 9.12 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.626% (RMSE 9.16 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.199% (RMSE 9.46 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 93.252% (RMSE 9.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.56% (RMSE 9.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.115% (RMSE 10.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.504% (RMSE 9.93 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.142% (RMSE 10.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 91.759% (RMSE 10.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 91.184% (RMSE 10.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.919% (RMSE 9.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 92.547% (RMSE 9.9 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 84.157% (RMSE 14.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.545% (RMSE 33.34 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.727% (RMSE 33.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.176% (RMSE 33.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.054% (RMSE 33.63 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.266% (RMSE 33.39 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 15.043% (RMSE 33.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 13.686% (RMSE 33.7 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 16.839% (RMSE 33.08 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 18.93% (RMSE 32.66 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 14.362% (RMSE 33.57 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 20.546% (RMSE 32.33 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 22.245% (RMSE 31.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.568% (RMSE 35.81 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.911% (RMSE 36.98 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.585% (RMSE 36.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.523% (RMSE 35.44 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.259% (RMSE 36.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -2.9% (RMSE 36.8 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.146% (RMSE 36.3 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.999% (RMSE 36.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.422% (RMSE 37.77 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.115% (RMSE 35.7 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.706% (RMSE 35.6 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.131% (RMSE 37.02 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.261% (RMSE 36.5 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.958% (RMSE 35.55 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.319% (RMSE 36.03 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -4.295% (RMSE 37.04 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.033% (RMSE 35.72 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.227% (RMSE 35.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -3.432% (RMSE 36.89 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.13% (RMSE 35.14 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.853% (RMSE 35.38 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.557% (RMSE 37.27 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.528% (RMSE 35.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.405% (RMSE 36.53 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.695% (RMSE 36.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.481% (RMSE 35.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.291% (RMSE 35.67 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -8.917% (RMSE 37.86 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.189% (RMSE 35.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.861% (RMSE 35.19 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.505% (RMSE 35.07 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.339% (RMSE 37.23 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.108% (RMSE 35.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.264% (RMSE 36.32 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.087% (RMSE 35.71 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.386% (RMSE 37.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.205% (RMSE 35.13 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.412% (RMSE 35.09 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 2.513% (RMSE 35.82 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 3.242% (RMSE 35.68 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.25% (RMSE 35.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.04% (RMSE 34.21 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.124% (RMSE 36.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 10.789% (RMSE 34.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 11.013% (RMSE 34.22 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.171% (RMSE 36.49 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.085% (RMSE 36.26 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 7.571% (RMSE 34.87 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -6.43% (RMSE 37.42 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.97% (RMSE 35.17 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.231% (RMSE 34.75 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -1.335% (RMSE 36.52 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 5.379% (RMSE 35.28 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -5.655% (RMSE 37.29 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 4.694% (RMSE 35.41 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 6.079% (RMSE 35.15 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 8.766% (RMSE 34.65 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.177% (RMSE 36.24 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.701% (RMSE 34.47 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 9.906% (RMSE 34.43 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.711% (RMSE 36.4 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.566% (RMSE 35.99 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: -0.181% (RMSE 36.31 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 0.122% (RMSE 36.25 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.445% (RMSE 36.01 vs. 36.27 null)
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 1.458% (RMSE 36.01 vs. 36.27 null)

Predictive success by metric is explored:

dfSmallR2Cloud <- as.data.frame(mtxSmallCloud) %>% 
    purrr::set_names(c("idx1", "idx2", "r2")) %>% 
    tibble::as_tibble() %>% 
    mutate(var1=possCloudVars[idx1], var2=possCloudVars[idx2], rn=row_number()) 
dfSmallR2Cloud %>% arrange(desc(r2)) %>% select(var1, var2, r2) %>% print(n=20)
## # A tibble: 666 × 3
##    var1                       var2                             r2
##    <chr>                      <chr>                         <dbl>
##  1 cloudcover_low             weathercode                   0.948
##  2 cloudcover_mid             weathercode                   0.937
##  3 weathercode                vapor_pressure_deficit        0.937
##  4 weathercode                soil_temperature_0_to_7cm     0.936
##  5 apparent_temperature       weathercode                   0.936
##  6 temperature_2m             weathercode                   0.935
##  7 weathercode                soil_temperature_28_to_100cm  0.933
##  8 weathercode                soil_temperature_7_to_28cm    0.932
##  9 relativehumidity_2m        weathercode                   0.931
## 10 dewpoint_2m                weathercode                   0.931
## 11 weathercode                doy                           0.929
## 12 et0_fao_evapotranspiration weathercode                   0.929
## 13 shortwave_radiation        weathercode                   0.926
## 14 diffuse_radiation          weathercode                   0.926
## 15 weathercode                soil_temperature_100_to_255cm 0.926
## 16 weathercode                month                         0.925
## 17 surface_pressure           weathercode                   0.925
## 18 weathercode                soil_moisture_7_to_28cm       0.925
## 19 cloudcover_high            weathercode                   0.924
## 20 winddirection_100m         weathercode                   0.923
## # ℹ 646 more rows
dfSmallR2Cloud %>% 
    pivot_longer(cols=c(var1, var2)) %>% 
    group_by(value) %>% 
    summarize(across(r2, .fns=list("min"=min, "mu"=mean, "max"=max))) %>% 
    ggplot(aes(x=fct_reorder(value, r2_mu))) + 
    coord_flip() + 
    geom_point(aes(y=r2_mu)) + 
    geom_errorbar(aes(ymin=r2_min, ymax=r2_max)) + 
    lims(y=c(NA, 1)) + 
    geom_hline(yintercept=1, lty=2, color="red") +
    labs(title="R-squared in every 2-predictor model including self and one other", 
         subtitle="Predicting cloud cover", 
         y="Range of R-squared (min-mean-max)", 
         x=NULL
    )

dfSmallR2Cloud %>% 
    arrange(desc(r2)) %>% 
    filter(var2!="weathercode", var1!="weathercode") %>% 
    select(var1, var2, r2) %>% 
    print(n=20)
## # A tibble: 630 × 3
##    var1                var2                             r2
##    <chr>               <chr>                         <dbl>
##  1 cloudcover_low      cloudcover_mid                0.906
##  2 cloudcover_low      cloudcover_high               0.834
##  3 cloudcover_low      direct_normal_irradiance      0.673
##  4 cloudcover_low      diffuse_radiation             0.670
##  5 cloudcover_low      soil_moisture_100_to_255cm    0.663
##  6 cloudcover_low      soil_moisture_0_to_7cm        0.662
##  7 surface_pressure    cloudcover_low                0.661
##  8 cloudcover_low      soil_temperature_28_to_100cm  0.661
##  9 cloudcover_low      soil_temperature_100_to_255cm 0.659
## 10 precipitation       cloudcover_low                0.656
## 11 cloudcover_low      direct_radiation              0.655
## 12 cloudcover_low      shortwave_radiation           0.654
## 13 cloudcover_low      soil_temperature_7_to_28cm    0.652
## 14 cloudcover_low      month                         0.652
## 15 cloudcover_low      et0_fao_evapotranspiration    0.652
## 16 temperature_2m      cloudcover_low                0.652
## 17 relativehumidity_2m cloudcover_low                0.651
## 18 cloudcover_low      soil_temperature_0_to_7cm     0.651
## 19 cloudcover_low      vapor_pressure_deficit        0.651
## 20 rain                cloudcover_low                0.651
## # ℹ 610 more rows
dfSmallR2Cloud %>% 
    filter(var2!="weathercode", var1!="weathercode") %>% 
    pivot_longer(cols=c(var1, var2)) %>% 
    group_by(value) %>% 
    summarize(across(r2, .fns=list("min"=min, "mu"=mean, "max"=max))) %>% 
    ggplot(aes(x=fct_reorder(value, r2_mu))) + 
    coord_flip() + 
    geom_point(aes(y=r2_mu)) + 
    geom_errorbar(aes(ymin=r2_min, ymax=r2_max)) + 
    lims(y=c(NA, 1)) + 
    geom_hline(yintercept=1, lty=2, color="red") +
    labs(title="R-squared in every 2-predictor model including self and one other", 
         subtitle="Predicting cloud cover (excluding variable paired with 'weathercode')", 
         y="Range of R-squared (min-mean-max)", 
         x=NULL
    )

Select combinations are explored using the full training dataset, with mtry=3:

possLargeVars <- c("weathercode", 
                   "cloudcover_low", 
                   "cloudcover_mid", 
                   "cloudcover_high"
                   )
possLargeVars
## [1] "weathercode"     "cloudcover_low"  "cloudcover_mid"  "cloudcover_high"
mtxLargeCloud <- matrix(nrow=0, ncol=4)

for(idx1 in 1:(length(possLargeVars)-2)) {
    for(idx2 in (idx1+1):(length(possLargeVars)-1)) {
        for(idx3 in (idx2+1):(length(possLargeVars))) {
            r2LargeCloud <- runFullRF(dfTrain=dfTrainCloud[,], 
                                      yVar="cloudcover", 
                                      xVars=possLargeVars[c(idx1, idx2, idx3)], 
                                      dfTest=dfTestCloud, 
                                      useLabel=keyLabel, 
                                      useSub=stringr::str_to_sentence(keyLabel), 
                                      isContVar=TRUE,
                                      mtry=3,
                                      makePlots=FALSE,
                                      returnData=TRUE
                                      )[["rfAcc"]][["r2"]]
            mtxLargeCloud <- rbind(mtxLargeCloud, c(idx1, idx2, idx3, r2LargeCloud))
        }
    }
}
## Growing trees.. Progress: 49%. Estimated remaining time: 31 seconds.
## Growing trees.. Progress: 98%. Estimated remaining time: 1 seconds.
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 98.104% (RMSE 5 vs. 36.27 null)
## Growing trees.. Progress: 52%. Estimated remaining time: 28 seconds.
## Growing trees.. Progress: 100%. Estimated remaining time: 0 seconds.
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 97.085% (RMSE 6.19 vs. 36.27 null)
## Growing trees.. Progress: 43%. Estimated remaining time: 41 seconds.
## Growing trees.. Progress: 84%. Estimated remaining time: 11 seconds.
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 95.218% (RMSE 7.93 vs. 36.27 null)
## Growing trees.. Progress: 43%. Estimated remaining time: 41 seconds.
## Growing trees.. Progress: 86%. Estimated remaining time: 9 seconds.
## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.998% (RMSE 0.17 vs. 36.27 null)
dfLargeR2Cloud <- as.data.frame(mtxLargeCloud) %>% 
    purrr::set_names(c("idx1", "idx2", "idx3", "r2")) %>% 
    tibble::as_tibble() %>% 
    mutate(var1=possLargeVars[idx1], var2=possLargeVars[idx2], var3=possLargeVars[idx3], rn=row_number()) 
dfLargeR2Cloud %>% arrange(desc(r2)) %>% select(var1, var2, var3, r2) %>% print(n=20)
## # A tibble: 4 × 4
##   var1           var2           var3               r2
##   <chr>          <chr>          <chr>           <dbl>
## 1 cloudcover_low cloudcover_mid cloudcover_high 1.00 
## 2 weathercode    cloudcover_low cloudcover_mid  0.981
## 3 weathercode    cloudcover_low cloudcover_high 0.971
## 4 weathercode    cloudcover_mid cloudcover_high 0.952

The three cloud cover subtypes, in combination, have almost perfect predictive power on overall cloud cover

A linear model is run for comparison:

lmMiniCloud <- allCity %>% 
    filter(tt=="train", year<2022) %>%
    select(c=cloudcover, l=cloudcover_low, m=cloudcover_mid, h=cloudcover_high) %>%
    lm(c~l*m*h, data=.) 
summary(lmMiniCloud)
## 
## Call:
## lm(formula = c ~ l * m * h, data = .)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.6112 -0.8934  0.0381  0.1074 19.3437 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.074e-01  7.397e-03  -14.52   <2e-16 ***
## l            9.280e-01  2.442e-04 3799.73   <2e-16 ***
## m            6.507e-01  3.641e-04 1787.35   <2e-16 ***
## h            3.093e-01  1.734e-04 1783.49   <2e-16 ***
## l:m         -4.984e-03  6.316e-06 -789.05   <2e-16 ***
## l:h         -1.401e-03  5.068e-06 -276.49   <2e-16 ***
## m:h         -1.996e-04  5.159e-06  -38.69   <2e-16 ***
## l:m:h       -2.158e-05  9.538e-08 -226.20   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.927 on 368102 degrees of freedom
## Multiple R-squared:  0.9935, Adjusted R-squared:  0.9935 
## F-statistic: 8.006e+06 on 7 and 368102 DF,  p-value: < 2.2e-16
ggMiniCloud <- predict(lmMiniCloud, 
                      newdata=allCity %>% 
                          filter(tt=="test", year==2022) %>% 
                          select(c=cloudcover, l=cloudcover_low, m=cloudcover_mid, h=cloudcover_high)
                      ) %>% 
    mutate(select(allCity %>% filter(tt=="test", year==2022), cloudcover), 
           pred=., 
           err=pred-cloudcover, 
           err2=err**2, 
           rnd5=round(cloudcover/5)*5
           ) %>% 
    group_by(rnd5) %>% 
    summarize(n=n(), across(.cols=where(is.numeric), .fns=mean))
ggMiniCloud %>% print(n=25)
## # A tibble: 21 × 6
##     rnd5     n cloudcover     pred     err    err2
##    <dbl> <dbl>      <dbl>    <dbl>   <dbl>   <dbl>
##  1     0  4697      0.208   0.0977 -0.111   0.0255
##  2     5   820      4.68    4.78    0.0924  0.119 
##  3    10   590      9.78   10.1     0.296   0.214 
##  4    15   483     14.9    15.4     0.440   0.393 
##  5    20   437     20.2    20.8     0.619   0.672 
##  6    25   429     25.1    25.8     0.712   0.846 
##  7    30  1073     30.0    30.7     0.754   0.791 
##  8    35   354     35.0    35.8     0.847   1.53  
##  9    40   300     40.2    40.9     0.766   2.15  
## 10    45   236     44.9    45.3     0.457   2.94  
## 11    50   219     50.0    50.3     0.254   4.63  
## 12    55   195     54.9    55.3     0.408   6.77  
## 13    60   250     59.9    61.3     1.37   13.4   
## 14    65   184     64.9    64.9     0.0396 11.5   
## 15    70   134     69.8    69.0    -0.810  15.0   
## 16    75   148     75.0    74.3    -0.681  19.3   
## 17    80   156     79.9    79.3    -0.654  24.4   
## 18    85   146     85.0    84.7    -0.227  32.4   
## 19    90   710     90.0    91.9     1.88   16.7   
## 20    95   155     94.7    90.8    -3.91   43.8   
## 21   100  1413     99.9   101.      0.984  37.4
ggMiniCloud %>% 
    select(rnd5, cloudcover, pred) %>%
    pivot_longer(cols=-c(rnd5)) %>%
    ggplot(aes(x=rnd5, y=value)) + 
    geom_line(aes(group=name, 
                  color=c("pred"="Predicted Mean", "cloudcover"="Actual Mean")[name]
                  )
              ) + 
    labs(title="Actual vs. Predicted Cloud Cover Using Linear Model on Holdout Data", 
         x="Actual cloud cover (rounded to nearest 5)", 
         y="Average cloud cover for metric"
         ) + 
    scale_color_discrete("Metric") + 
    geom_abline(slope=1, intercept=0, lty=2)

The linear model generally makes strong predictions, though with generally lower accuracy on cloudier days. Distribution of errors is explored:

predict(lmMiniCloud, 
        newdata=allCity %>% 
            filter(tt=="test", year==2022) %>% 
            select(c=cloudcover, l=cloudcover_low, m=cloudcover_mid, h=cloudcover_high)
        ) %>% 
    mutate(select(allCity %>% filter(tt=="test", year==2022), cloudcover), 
           pred=., 
           err=pred-cloudcover, 
           err2=err**2, 
           rnd5=round(cloudcover/5)*5, 
           rndCat=case_when(cloudcover<10~"1) clear (<10)", 
                            cloudcover<50~"2) partly (10-50)", 
                            cloudcover<90~"3) mostly (50-90)", 
                            TRUE~"4) cloudy (>90)"
                            )
           ) %>%
    ggplot(aes(x=err)) + 
    geom_histogram(fill="lightblue") + 
    labs(title="Errors in linear model cloud cover prediction by amount of clouds", 
         x="Error (Predicted minus Actual)", 
         y="# Observations"
         ) + 
    facet_wrap(~rndCat, scales="free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Predictions for the random forest model are also explored:

rfSubCloudPred <- runFullRF(dfTrain=allCity %>% filter(tt=="train", year<2022), 
                            yVar="cloudcover", 
                            xVars=c(varsTrain[str_detect(varsTrain, pattern="cloudcover_")]), 
                            dfTest=allCity %>% filter(tt=="test", year==2022), 
                            useLabel=keyLabel, 
                            useSub=stringr::str_to_sentence(keyLabel), 
                            isContVar=TRUE,
                            mtry=3,
                            rndTo=-1L,
                            refXY=TRUE,
                            returnData=TRUE
                            )[["tstPred"]]
## Growing trees.. Progress: 46%. Estimated remaining time: 36 seconds.
## Growing trees.. Progress: 98%. Estimated remaining time: 1 seconds.

## 
## R-squared of predictions based on pre-2022 training data applied to 2022 holdout dataset is: 99.998% (RMSE 0.17 vs. 36.27 null)
## `geom_smooth()` using formula = 'y ~ x'

rfSubCloudPred
## # A tibble: 13,129 × 84
##    src   time                date        hour temperature_2m relativehumidity_2m
##    <chr> <dttm>              <date>     <int>          <dbl>               <int>
##  1 NYC   2022-01-01 00:00:00 2022-01-01     0            9.2                  97
##  2 NYC   2022-01-01 01:00:00 2022-01-01     1            8.9                  98
##  3 NYC   2022-01-01 10:00:00 2022-01-01    10            9.8                  98
##  4 NYC   2022-01-01 11:00:00 2022-01-01    11           10.2                  99
##  5 NYC   2022-01-02 00:00:00 2022-01-02     0            9.7                  99
##  6 NYC   2022-01-02 02:00:00 2022-01-02     2            9.7                  97
##  7 NYC   2022-01-02 03:00:00 2022-01-02     3            9.7                 100
##  8 NYC   2022-01-02 05:00:00 2022-01-02     5            9.7                  99
##  9 NYC   2022-01-02 12:00:00 2022-01-02    12           12.5                  92
## 10 NYC   2022-01-02 16:00:00 2022-01-02    16           12.4                  90
## # ℹ 13,119 more rows
## # ℹ 78 more variables: dewpoint_2m <dbl>, apparent_temperature <dbl>,
## #   pressure_msl <dbl>, surface_pressure <dbl>, precipitation <dbl>,
## #   rain <dbl>, snowfall <dbl>, cloudcover <int>, cloudcover_low <int>,
## #   cloudcover_mid <int>, cloudcover_high <int>, shortwave_radiation <dbl>,
## #   direct_radiation <dbl>, direct_normal_irradiance <dbl>,
## #   diffuse_radiation <dbl>, windspeed_10m <dbl>, windspeed_100m <dbl>, …

Distribution of errors from the random forest model is explored:

rfSubCloudPred %>% 
    mutate(err=pred-cloudcover, 
           err2=err**2, 
           rnd5=round(cloudcover/5)*5, 
           rndCat=case_when(cloudcover<10~"1) clear (<10)", 
                            cloudcover<50~"2) partly (10-50)", 
                            cloudcover<90~"3) mostly (50-90)", 
                            TRUE~"4) cloudy (>90)"
                            )
           ) %>%
    ggplot(aes(x=err)) + 
    geom_histogram(fill="lightblue") + 
    labs(title="Errors in linear model cloud cover prediction by amount of clouds", 
         x="Error (Predicted minus Actual)", 
         y="# Observations"
         ) + 
    facet_wrap(~rndCat, scales="free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

There are essentially no prediction errors at any level of overall cloudiness